{"id":3028,"date":"2019-12-29T01:14:04","date_gmt":"2019-12-29T00:14:04","guid":{"rendered":"https:\/\/www.webotlet.hu\/?p=3028"},"modified":"2019-12-29T01:22:07","modified_gmt":"2019-12-29T00:22:07","slug":"java-programozas-2017-majusi-emelt-szakmai-informatika-erettsegi-txt2srt-1-verzio","status":"publish","type":"post","link":"https:\/\/www.webotlet.hu\/?p=3028","title":{"rendered":"Java programoz\u00e1s \u2013 2017 m\u00e1jusi emelt szakmai informatika \u00e9retts\u00e9gi \u2013 txt2srt (1. verzi\u00f3)"},"content":{"rendered":"<p>A feladat le\u00edr\u00e1s\u00e1t, melynek a megold\u00e1s\u00e1t k\u00f6zz\u00e9teszem <a href=\"https:\/\/www.webotlet.hu\/wp-content\/uploads\/2019\/12\/e_infoism_17maj_txt2srt.pdf\">innen<\/a> t\u00f6ltheted le.<\/p>\n<p>Saj\u00e1t oszt\u00e1ly:<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\/**\r\n *\r\n * @author https:\/\/webotlet.hu\r\n *\/\r\npackage webotlet_17maj_szakmai_e_txt2srt;\r\n\r\npublic class IdozitettFelirat\r\n{\r\n  private String idozites;\r\n  private String felirat;\r\n  private int szavakSzama;\r\n\r\n  public IdozitettFelirat(String idozites, String felirat)\r\n  {\r\n    this.idozites = srtIdozites(idozites);\r\n    this.felirat = felirat;\r\n    szavakSzama = szavakSzama(felirat);\r\n  }\r\n  \r\n  public int szavakSzama(String felirat)\r\n  {\r\n    return felirat.split(&quot; &quot;).length;\r\n  }\r\n  \r\n  private String srtIdozites(String idozites)\r\n  {\r\n    \/\/65:31 - 65:34\r\n    \/\/01:05:31 --&gt; 01:05:34\r\n    String&#x5B;] ido1 = new String&#x5B;3];\r\n    String&#x5B;] ido2 = new String&#x5B;3];\r\n    \r\n    int tmp = Integer.parseInt(idozites.substring(0,2));\r\n    ido1&#x5B;0] = String.format(&quot;%02d&quot;, tmp \/ 60);\r\n    ido1&#x5B;1] = String.format(&quot;%02d&quot;, tmp % 60);\r\n    ido1&#x5B;2] = idozites.substring(3,5);\r\n    \r\n    tmp = Integer.parseInt(idozites.substring(8,10));\r\n    ido2&#x5B;0] = String.format(&quot;%02d&quot;, tmp \/ 60);\r\n    ido2&#x5B;1] = String.format(&quot;%02d&quot;, tmp % 60);\r\n    ido2&#x5B;2] = idozites.substring(11);\r\n    \r\n    return String.join(&quot;:&quot;, ido1) + &quot; --&gt; &quot; + String.join(&quot;:&quot;, ido2);\r\n  }\r\n\r\n  public String getIdozites()\r\n  {\r\n    return idozites;\r\n  }\r\n\r\n  public String getFelirat()\r\n  {\r\n    return felirat;\r\n  }\r\n\r\n  public int getSzavakSzama()\r\n  {\r\n    return szavakSzama;\r\n  }\r\n\r\n  @Override\r\n  public String toString()\r\n  {\r\n    return &quot;IdozitettFelirat{&quot; + &quot;idozites=&quot; + idozites\r\n      + &quot;, felirat=&quot; + felirat + &quot;, szavakSzama=&quot; + szavakSzama + '}';\r\n  }\r\n}\r\n<\/pre>\n<p>A feladat megold\u00e1sai:<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\/**\r\n *\r\n * @author https:\/\/webotlet.hu\r\n *\/\r\npackage webotlet_17maj_szakmai_e_txt2srt;\r\n\r\nimport java.io.IOException;\r\nimport java.io.RandomAccessFile;\r\nimport java.util.ArrayList;\r\n\r\npublic class Webotlet_17maj_szakmai_e_Txt2srt\r\n{\r\n  public static void main(String&#x5B;] args)\r\n  {\r\n    ArrayList&lt;IdozitettFelirat&gt; feliratok = new ArrayList&lt;&gt;();\r\n    \r\n    try\r\n    {\r\n      RandomAccessFile raf = new RandomAccessFile(&quot;feliratok.txt&quot;, &quot;r&quot;);\r\n      String sor;\r\n      for( sor = raf.readLine(); sor != null; sor = raf.readLine() )\r\n      {\r\n        feliratok.add(new IdozitettFelirat(sor, raf.readLine()));\r\n      }\r\n      raf.close();\r\n    }\r\n    catch( IOException e )\r\n    {\r\n      System.out.println(&quot;HIBA&quot;);\r\n    }\r\n    \r\n    System.out.println(&quot;5. feladat - feliratok sz\u00e1ma: &quot; + feliratok.size());\r\n    \r\n    int max = 0;\r\n    for( int i = 1; i &lt; feliratok.size(); i++ )\r\n    {\r\n      if( feliratok.get(i).getSzavakSzama() &gt; feliratok.get(max).getSzavakSzama() )\r\n      {\r\n        max = i;\r\n      }\r\n    }\r\n    \r\n    System.out.println(&quot;7. feladat - Legt\u00f6bb sz\u00f3b\u00f3l \u00e1ll\u00f3 felirat:&quot;);\r\n    System.out.println(feliratok.get(max).getFelirat());\r\n    \r\n    try\r\n    {\r\n      RandomAccessFile ki = new RandomAccessFile(&quot;felirat.srt&quot;, &quot;rw&quot;);\r\n      ki.setLength(0);\r\n      \r\n      for( int i = 0; i &lt; feliratok.size(); i++ )\r\n      {\r\n        ki.writeBytes((i + 1) + &quot;\\n&quot; + feliratok.get(i).getIdozites()\r\n          + &quot;\\n&quot; + feliratok.get(i).getFelirat() + &quot;\\n\\n&quot;);\r\n      }\r\n      ki.close();\r\n    }\r\n    catch( IOException e )\r\n    {\r\n      System.out.println(&quot;HIBA&quot;);\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<p>Ha hib\u00e1t tal\u00e1lsz benne, k\u00e9rlek jelezd!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A feladat le\u00edr\u00e1s\u00e1t, melynek a megold\u00e1s\u00e1t k\u00f6zz\u00e9teszem innen t\u00f6ltheted le. Saj\u00e1t oszt\u00e1ly: \/** * * @author https:\/\/webotlet.hu *\/ package webotlet_17maj_szakmai_e_txt2srt; public class IdozitettFelirat { private String idozites; private String felirat; private int szavakSzama; public IdozitettFelirat(String idozites, String felirat) { this.idozites <a class=\"more-link\" href=\"https:\/\/www.webotlet.hu\/?p=3028\">Tov\u00e1bb <span class=\"screen-reader-text\">  Java programoz\u00e1s \u2013 2017 m\u00e1jusi emelt szakmai informatika \u00e9retts\u00e9gi \u2013 txt2srt (1. verzi\u00f3)<\/span><span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[215],"tags":[],"class_list":["post-3028","post","type-post","status-publish","format-standard","hentry","category-java-szakmai-erettsegi-feladatok"],"_links":{"self":[{"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=\/wp\/v2\/posts\/3028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3028"}],"version-history":[{"count":3,"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=\/wp\/v2\/posts\/3028\/revisions"}],"predecessor-version":[{"id":3032,"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=\/wp\/v2\/posts\/3028\/revisions\/3032"}],"wp:attachment":[{"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}