
JAVA问题(英文的)
Writeaprogramthatassignsseatsonanairplane.Assumetheairplanehas20seatsinthefirstclass(...
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 展开
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 展开
1个回答
2014-03-03
展开全部
不让用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好难受
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询