Sothian

Untitled

Nov 22nd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.77 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.Scanner;
  3.  
  4. public class TestClass {
  5.     public static void readFile(File file) throws IOException {
  6.         BufferedReader br = new BufferedReader(new FileReader(file));
  7.         String line;
  8.         while ((line = br.readLine()) != null)
  9.             System.out.println(line);
  10.     }
  11.    
  12.     public static void main(String[] args) throws IOException {
  13.        
  14.         // VERIFY CLASSES TEST
  15.         VerifyDate x = new VerifyDate();
  16.         x.verify("12/12/2018");
  17.         VerifyPhoneNumber y = new VerifyPhoneNumber();
  18.         y.verify("886542164");
  19.        
  20.        
  21.         // CATEGORIES TEST
  22.         File file;
  23.         Scanner scan= new Scanner(System.in);
  24.         // Test the categories by typing "Yes"
  25.         System.out.println("Do you want to see categories of offenses? Press 'Yes' to see.");
  26.         String checkAttachements = scan.nextLine();
  27.         System.out.println(checkAttachements);
  28.         if(checkAttachements=="Yes") {
  29.             do {
  30.                 // Test the categories by choosing attachement
  31.                 System.out.println("Choose attachement 1-5 (Type 1,2,3,4 or 5) to see categories in it");
  32.                 int attachement = scan.nextInt();
  33.                 switch(attachement) {
  34.                 case 1:
  35.                     file = new File("zalacznik1.txt");
  36.                     readFile(file);
  37.                     break;
  38.                 case 2:
  39.                     file = new File("zalacznik2.txt");
  40.                     readFile(file);
  41.                     break;
  42.                 case 3:
  43.                     file = new File("zalacznik3.txt");
  44.                     readFile(file);
  45.                     break;
  46.                 case 4:
  47.                     file = new File("zalacznik4.txt");
  48.                     readFile(file);
  49.                     break;
  50.                 case 5:
  51.                     file = new File("zalacznik5.txt");
  52.                     readFile(file);
  53.                     break;
  54.                 default:
  55.                     System.out.println("Unknown attachement");
  56.                     break;
  57.                 }
  58.                 System.out.println("Stop or again? Press Exit if you want to stop or No if not");
  59.                 checkAttachements = scan.nextLine();
  60.             } while(checkAttachements!="Exit");
  61.         }
  62.     }
  63. }
Add Comment
Please, Sign In to add comment