import java.util.Scanner;
public class MainApp
{
private Scanner keyboard = new Scanner(System.in);
public static void main(String[] args)
{
new MainApp().start();
}
public void start()
{
Airline airline1 = new Airline("AerLingus");
PlaneStore planeStore = new PlaneStore("Aer Lingus");
Flight p1 = new Flight("Aer Lingus","A01", 150.5, 10.5, 500, Flight.AIRPLANETYPE.AIRBUS);
Flight p2 = new Flight("Aer Lingus","B01", 50.3, 1.5, 91, Flight.AIRPLANETYPE.CORPORATE);
Flight p3 = new Flight("Aer Lingus","C01", 12.2, -3.1, 56, Flight.AIRPLANETYPE.AIRBUS);
Flight p4 = new Flight("Ryan Air","D01", 10.5, 1.5, 430, Flight.AIRPLANETYPE.PRIVATE);
Flight p5 = new Flight("Ryan Air","E01", 0.3, 2.1, 101, Flight.AIRPLANETYPE.CORPORATE);
Flight p6 = new Flight("Ryan Air","F01", 2.2, -3, 291, Flight.AIRPLANETYPE.AIRBUS);
planeStore.add(p1);
planeStore.add(p2);
planeStore.add(p3);
planeStore.print();
airline1.add(planeStore);
airline1.add(planeStore);
airline1.add(planeStore);
airline1.printPlane();
}
}
import java.util.HashMap;
public class Airline
{
private String airlineName;
private HashMap<String, PlaneStore> map;
public Airline(String airlineName)
{
this.airlineName = "";
map = new HashMap<String, PlaneStore>();
}
public void add(PlaneStore plane)
{
map.put(airlineName, plane);
}
public void remove(String flight)
{
map.remove(flight);
}
public void printPlane()
{
System.out.println("\n********Flight List********");
for (PlaneStore plane: map.values()) {
//System.out.println(plane);
// class
// or:
System.out.println(airlineName);
System.out.println(plane.toString());
}
}
}
嘿,我想打印出飞机商店。平面存储包含字符串和航班的哈希图。这就是 flight.add/print 进入主应用程序的地方。但我现在希望航空公司和航班并行打印,所以我放了一个航空公司商店,我试图把飞机商店和航空公司一起打印出来,但我得到的只是一个内存地址,任何人都可以帮我解决这个问题。