I'm doing a project for university of an app that sells flight tickets. in the part of offering the plane seats available,I'm making them with hashmaps, putting the passenger name, and the row & seat as the key. I don´t know how to use the scanner to ask the client to write down the row and seat he wants, and to mark the seat as occupied. Shall I create a class called seat? if you have some idea I would be very thankful.
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);
}
and the other class I made is:
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;
}
}
Currently what this code is doing is that it is using your seat object as a key and is storing the name as a value. You should be storing the seat such as it's row and seat number as the key and as a value you could set the flag which would tell if that seat is occupied. So whenever you would create a seat you would put true in the hashmap with that key(seat number, row, name) and whenever a new client requests the same key you can see if the seat is occupied or not.