I have a HashMap that shows a Car Parking space as the Key and a Vehicle Number Plate as the value, I have it so that the user inputs the number plate of the vehicle when they're retreiving their vehicle, I would then like to remove / replace the value for the number plate they just entered.
For example, the output would go from:
Parking Space: 1, Vehicle Registration: ABCD123
to this:
Parking Space: 1, Vehicle Registration: "Empty" / null
the tempVehicle.plate is a String that holds a user entered number plate.
public int key = 1;
HashMap<Integer, String> zone_1 = new HashMap<Integer, String>();
public void addToZone1(Vehicle tempVehicle){
if (key < 5) {
zone_1.put(key, tempVehicle.plate);
key++;
System.out.println(zone_1.toString());
}
else {
System.out.println("There is no more room in this Zone!");
}
}
This is the only thing I have been able to come up with for this, I hope it's possible, I should of looked before hand I guess.
public void pickingVehicleUp() {
System.out.println("Please enter number plate: ");
input = new Scanner(System.in);
String PLATE = input.nextLine();
if (zone_1.containsValue(PLATE)) {
}
}
I was looking to add onto the if statement or change in completely, whatever I need to do to make this work, thanks in advance
Aucun commentaire:
Enregistrer un commentaire