我正在做一个销售机票的应用程序的大学项目。 在提供飞机座位的部分,我正在做他们与hashmaps,把乘客的名字,和行&座位为关键。 我不知道如何使用扫描仪要求客户写下他想要的排和座位,并将座位标记为已占用。我应该创建一个名为座位的班级吗?如果你有一些想法,我会非常感激。HashMap售飞机票java
public AsientosConNombre(Integer row, String seat) {
super(row, seat);
}
public static void main(String[] args) {
String nombrePasajero = Scanner.getString("Enter your name: ");
Seat1 asientopasajero= new Seat1(AsientosConNombre);
//creo el hashmap
HashMap<Seat1, String> Asientos = new HashMap<Seat1, String>();
//llenamos el hashmap con la informacion ingresada por el pasajero.
Asientos.put(asientopasajero, nombrePasajero);
//esto deberia devolver la app clientes cuando el usuario indica su nombre para saber su vuelo.
// (ademas del horario y fecha del vuelo)
System.out.println("Your information: "+ Asientos);
}
,我提出的其他类:
public class Seat1 {
Integer row = Scanner.getInt("Enter your row: ");
String seat = Scanner.getString("Enter your seat: ");
public Seat1(Integer row, String seat) {
this.row = row;
this.seat = seat;
}
public boolean full(boolean occupied){
return occupied;
}
}