作业帮 > 综合 > 作业

JAVA问题(英文的)

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/14 04:48:34
JAVA问题(英文的)
Write a program that assigns seats on an airplane.Assume the airplane has 20 seats in the first class (5 rows of 4 seats each,separated by an aisle) and 90 seats in economy class (15 rows of 6 seats each,separated by an aisle).Your program should take three commands:add passengers,show seating,and quit.When passengers are added,ask for the class (first or economy),the number of passengers traveling together (1 or 2 in the first class; 1 to 3 in economy),and the seating preference (aisle or window in the first class; aisle,center,or window in economy).Then try to find a match and assign the seats.If no match exists,print a message stating as such.Your solution should include a class Airplane that is not coupled with the Scanner or Printstream classes.
Your main class should be called AirplaneSeatingSystem.
/**
This program implements an airplane seating system.
*/
public class AirplaneSeatingSystem
{
public static void main(String[] args)
{
AirplaneMenu menu = new AirplaneMenu();
menu.run();
}
}
Here is a sample program run.(Red items are possible user inputs.)
A)dd S)how Q)uit
A
F)irst E)conomy
F
Passengers?(1-2)
1
A)isle W)indow
A
A)dd S)how Q)uit
A
F)irst E)conomy
E
Passengers?(1-3)
2
A)isle C)enter W)indow
W
A)dd S)how Q)uit
A
F)irst E)conomy
E
Passengers?(1-3)
3
A)dd S)how Q)uit
A
F)irst E)conomy
E
Passengers?(1-3)
3
A)dd S)how Q)uit
S
1:.* ..
2:....
3:....
4:....
5:....
6:**.***
7:*** ...
8:......
9:......
10:......
11:......
12:......
13:......
14:......
15:......
16:......
17:......
18:......
19:......
20:......
A)dd S)how Q)uit
Q
不让用Scanner和Printstream
是不能导入其他包么
再问: 对的
再答: public class AirplaneSeatingSystem {

    public static void main(String[] args) {
        AirplaneMenu menu = new AirplaneMenu();
        menu.run();
    }
}public class Airplane {
private int[][] first;
private int[][] economy;

public Airplane() {
this.setFirst(new int[5][4]);
this.setEconomy(new int[15][6]);
}

public boolean add(boolean isFirst, int passengerNum, char position) {
}
}public class AirplaneMenu {
private static Airplane airplane;

public AirplaneMenu() {
AirplaneMenu.airplane = new Airplane();
}

public void run() {
try {
entrance();
} catch (Exception e) {
System.out.println("Error");
e.printStackTrace();
}
}

private void entrance() throws Exception {
}

private boolean add() throws Exception {
}

private void show() {
}

private void quit() {
}
}
没写注释,看不懂再问吧我就试了一个add,不知道有bug没获取输入的时候屏蔽回车和制表符了,有问题
没有Scanner好难受