Package main.company

Examples of main.company.MyCompany


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
        MyCompany company = new MyCompany();
        while(true){
        System.out.println("Welcome!\nThis application represents your company.\n\nPlease choose an option:"
                + "\n1. Add worker.\n2. Get worker.\n3. Delete worker.\n4. Show all workers.\n5. Show all workers sorted by salary.\n6. Exit.");
        int option = Integer.parseInt(keyboard.readLine());
        switch(option){
            default:
                System.out.println("\n\nWrong option! Try again please!\n\n");
                break;
            case 6:
                System.exit(0);
                break;
            case 1:
                System.out.println("Choose the type of worker:\n1. Simple worker.\n2. Driver.\n3. Manager.");
                int workerType = Integer.parseInt(keyboard.readLine());
                switch(workerType){
                    default:
                        System.out.println("\n\nWrong worker type! Try again!\n");
                        break;
                    case 1:
                        Worker worker = new Worker(keyboard.readLine(),Double.parseDouble(keyboard.readLine()));
                        company.addWorker(worker);
                        if(company.addWorker(worker)){
                            System.out.println("\n\nWorker was added to company.\n");
                        }else{
                            System.out.println("\n\nWorker wasn't added to company! Try again!\n");
                        }
                        break;
                    case 2:
                        Driver driver = new Driver(keyboard.readLine(),Double.parseDouble(keyboard.readLine()),Boolean.parseBoolean(keyboard.readLine()));
                        company.addWorker(driver);
                        if(company.addWorker(driver)){
                            System.out.println("\n\nDriver was added to company.\n");
                        }else{
                            System.out.println("\n\nDriver wasn't added to company! Try again!\n");
                        }
                        break;
                    case 3:
                        Manager manager = new Manager(keyboard.readLine(),Double.parseDouble(keyboard.readLine()),Double.parseDouble(keyboard.readLine()));
                        company.addWorker(manager);
                        if(company.addWorker(manager)){
                            System.out.println("\n\nManager was added to company.\n");
                        }else{
                            System.out.println("\n\nManager wasn't added to company! Try again!\n");
                        }
                        break;
                }
                break;
            case 2:
                System.out.print("Please input the number of wanted worker/driver/manager: ");
                int index = Integer.parseInt(keyboard.readLine());
                company.getWorker(index);
               break;
            case 3:
                System.out.println("Please input the number of worker/driver/manager you want to delete: ");
                int delIndex = Integer.parseInt(keyboard.readLine());
                company.delWorker(delIndex);
        }
           
      
       
       
View Full Code Here

TOP

Related Classes of main.company.MyCompany

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.