Class bus:
1. import java.util.Scanner;
2. public class Bus {
3. String type [] = new String[100];
4. int enginenumbe [] = new int[100];
5. int seatingcapacity [] = new int[100];
6. int route [] = new int[100];
7. int j;
8. void BUS(int i) {
9. System.out.print(\"请输入汽车数量:\");
10. Scanner s=new Scanner(System.in);
11. int ii=s.nextInt();
12. for(i=0;i 14. System.out.print(\"请输入第\"+(i+1)+\"辆汽车的型号,发动机编号,座位容量及路线:\"); 15. Scanner a=new Scanner(System.in); 16. type[i]=a.nextLine(); 17. Scanner b=new Scanner(System.in); 18. enginenumbe[i]=b.nextInt(); 19. Scanner c=new Scanner(System.in); 20. seatingcapacity[i]=c.nextInt(); 21. Scanner d=new Scanner(System.in); 22. route[i]=d.nextInt(); 23. } 24. 25. for(j=0;j 27. System.out.print(\"第\"+(j+1)+\"辆车的型号,发动机编号,座位容量及路线为:\"); 28. System.out.println(type[j]+\" \"+enginenumbe[j]+\" \"+seatingcapacity[j]+\" \"+route[j]); 29. } 30. } 31. } Class Route: 1. import java.util.Scanner; 2. public class Route { 3. int thenumberofstops [] = new int[100]; 4. String startingstation [] = new String[100]; 5. String destination [] = new String[100]; 6. String runningtime [] = new String[100]; 7. int j; 8. void ROUTE() { 9. int i; 10. System.out.print(\"请输入线路数量:\"); 11. Scanner s=new Scanner(System.in); 12. int ii=s.nextInt(); 13. for(i=0;i 15. System.out.print(\"请输入第\"+(i+1)+\"条线路的停止次数,起始站,终点及运行时间:\"); 16. Scanner a=new Scanner(System.in); 17. thenumberofstops[i]=a.nextInt(); 18. Scanner b=new Scanner(System.in); 19. startingstation[i]=b.nextLine(); 20. Scanner c=new Scanner(System.in); 21. destination[i]=c.nextLine(); 22. Scanner d=new Scanner(System.in); 23. runningtime[i]=d.nextLine(); 24. } 25. 26. for(j=0;j 28. System.out.print(\"第\"+(j+1)+\"条线路的停止次数,起始站,终点及运行时间:\"); 29. System.out.println(thenumberofstops[j]+\" \"+startingstation[j]+\" \"+destination[j]+\" \"+runningtime[j]); 30. } 31. } 32. } Class employee: 1. import java.util.Scanner; 2. ublic class Employee { 3. String name [] = new String[100]; 4. int ID [] = new int[100]; 5. int age [] = new int[100]; 6. double salary [] = new double[100]; 7. String department [] = new String[100]; 8. int j; 9. void EMPLOYEE() { 10. int i; 11. System.out.print(\"请输入员工数量:\"); 12. Scanner s=new Scanner(System.in); 13. int ii=s.nextInt(); 14. for(i=0;i 16. System.out.print(\"请输入第\"+(i+1)+\"名员工的姓名,编号,年龄,薪资及所在部门:\"); 17. Scanner a=new Scanner(System.in); 18. name[i]=a.nextLine(); 19. Scanner b=new Scanner(System.in); 20. ID[i]=b.nextInt(); 21. Scanner c=new Scanner(System.in); 22. age[i]=c.nextInt(); 23. Scanner d=new Scanner(System.in); 24. salary[i]=d.nextInt(); 25. Scanner e=new Scanner(System.in); 26. department[i]=d.nextLine(); 27. } 28. 29. for(j=0;j 31. System.out.print(\"第\"+(j+1)+\"名员工的姓名,编号,年龄,薪资及所在部门:\"); 32. System.out.println(name[j]+\" \"+ID[j]+\" \"+age[j]+\" \"+salary[j]+\" \"+department[j]); 33. } 34. } Class Passenger: 1. import java.util.Scanner; 2. public class Passenger { 3. String name [] = new String[100]; 4. char sex [] = new char[100]; 5. int age [] = new int[100]; 6. String message [] = new String[100]; 7. int j; // 8. void PASSENGER() { 9. int i; 10. System.out.print(\"请输入顾客数量:\"); 11. Scanner s=new Scanner(System.in); 12. int ii=s.nextInt(); 13. for(i=0;i 15. System.out.print(\"请输入第\"+(i+1)+\"辆顾客的姓名,性别,年龄及信息:\"); 16. Scanner a=new Scanner(System.in); 17. name[i]=a.nextLine(); 18. Scanner b=new Scanner(System.in); 19. sex[i]=b.next().charAt(0); 20. Scanner c=new Scanner(System.in); 21. age[i]=c.nextInt(); 22. Scanner d=new Scanner(System.in); 23. message[i]=d.nextLine(); 24. } 25. 26. for(j=0;j 28. System.out.print(\"第\"+(j+1)+\"辆顾客的姓名,性别,年龄及信息:\"); 29. System.out.println(name[j]+\" \"+sex[j]+\" \"+age[j]+\" \"+message[j]); 30. } 31. } 32. } test: 1. public class test { 2. public static void main(String[] args) { 3. Bus obj = new Bus(); 4. Employee obj1 = new Employee(); 5. Passenger obj2 = new Passenger(); 6. Route obj3 = new Route(); 7. //调用四个class 8. obj.BUS(0); 9. obj1.EMPLOYEE(); 10. obj2.PASSENGER(); 11. obj3.ROUTE(); 12. //调用四个class中的方法 13. } 因篇幅问题不能全部显示,请点此查看更多更全内容