Advertisement
Guest User

15.Feladat.

a guest
Dec 28th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.38 KB | None | 0 0
  1.   import java.io.*;
  2.   import java.util.Scanner;
  3. public class KissLaszlo_15 {
  4.    
  5. static void a (){
  6. System.out.println ("Add meg a keresendő előadót:");//Blue Stahli; Celldweller; Scandroid; Voicians; I Will Never Be The Same, a lehetséges találatok.
  7. try {
  8. Scanner be = new Scanner(System.in);
  9. String artist = be.nextLine();
  10. FileInputStream fstream = new FileInputStream("lista.txt");
  11. DataInputStream in = new DataInputStream(fstream);
  12. BufferedReader br = new BufferedReader(new InputStreamReader(in));
  13. String strLine;
  14. while ((strLine = br.readLine())!= null) {
  15. CharSequence arg0 = artist;
  16. if (strLine.contains(arg0)) {
  17. System.out.println(strLine);
  18. }
  19. else{System.out.println ("Nincs találat");
  20. }
  21. }
  22. in.close();
  23. } catch (Exception e) {
  24. System.err.println("Error: " + e.getMessage());
  25. }
  26. }
  27.  
  28. static void b (){ //Nincs kész
  29. try {
  30. FileInputStream fstream = new FileInputStream("lista2.txt");
  31. DataInputStream in = new DataInputStream(fstream);
  32. BufferedReader br = new BufferedReader(new InputStreamReader(in));
  33. String strLine;
  34. while ((strLine = br.readLine())!= null) {
  35. }
  36. in.close();
  37. } catch (Exception e) {
  38. System.err.println("Error: " + e.getMessage());
  39. }
  40. }
  41.    
  42.  
  43.  
  44. static void c (){
  45. System.out.println ("Nincs Kész");
  46. }
  47.  
  48. static void d (){
  49. System.out.println ("Nincs Kész");
  50. }
  51.    
  52.  public static void main(String args[]){
  53.    
  54.    
  55.     System.out.println ("Súgó:");
  56.         System.out.println ("A.Feladat: Bekér egy Előadó nevet majd megmutatja, hogy van-e a listán.");
  57.         System.out.println ("B.Feladat: Megnézi, hogy a listán valóban egyre rövidebb dalok szerepelnek-e.");
  58.         System.out.println ("C.Fealdat: A listát végtelenítve megadja a K másodpercnél játszódó zene címét");
  59.         System.out.println ("D.Feladat: Megkeresi az azonos című dalokat és megmondja melyik a leghosszabb.");
  60.        
  61.             Scanner menu = new Scanner(System.in);
  62.             int a = 7;
  63.             System.out.println("(1) A. Feladat");
  64.             System.out.println("(2) B. Feladat");
  65.             System.out.println("(3) C. Feladat");
  66.             System.out.println("(4) D. Feladat");
  67.             System.out.print("Adja meg a valasztott menupontot: ");
  68.             a = menu.nextInt();
  69.             switch(a){
  70.                 case 1 : a(); break;
  71.                 case 2 : b(); break;
  72.                 case 3 : c(); break;
  73.                 case 4 : d(); break;
  74.                 default : System.out.println("Hiba!");}
  75.         }  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement