T
Tuurbo46
This post follows my previous post. I am struggling to write to a
hashtable. I have included more code this time. See below:
public void handleAddPlane()
{
String planeRegisNum = "";
String planeModel = "";
System.out.println("User wants to add a plane");
System.out.println("Please enter plane registation number: ");
planeRegisNum = readKeyboard().toUpperCase();
while(planeRegisNum.equals("")){
System.out.println("Wrong entry: ");
}
System.out.println("Please enter plane model number: ");
planeModel = readKeyboard().toUpperCase();
while(planeModel.equals("")){
System.out.println("Wrong entry: ");
}
Block b[] = seatBlocks(planeModel);
AirPlane plane = new AirPlane(b, planeRegisNum, planeModel);
if (!airPlanes.containsKey(planeRegisNum))
{
try {
airPlanes.put(planeRegisNum, plane);
}
catch(Exception ex){
System.out.println("Problem Adding a Plane to a hash
table");
}
System.out.println("Airplane was successfully added");
}
}
Thanks tuurbo
hashtable. I have included more code this time. See below:
public void handleAddPlane()
{
String planeRegisNum = "";
String planeModel = "";
System.out.println("User wants to add a plane");
System.out.println("Please enter plane registation number: ");
planeRegisNum = readKeyboard().toUpperCase();
while(planeRegisNum.equals("")){
System.out.println("Wrong entry: ");
}
System.out.println("Please enter plane model number: ");
planeModel = readKeyboard().toUpperCase();
while(planeModel.equals("")){
System.out.println("Wrong entry: ");
}
Block b[] = seatBlocks(planeModel);
AirPlane plane = new AirPlane(b, planeRegisNum, planeModel);
if (!airPlanes.containsKey(planeRegisNum))
{
try {
airPlanes.put(planeRegisNum, plane);
}
catch(Exception ex){
System.out.println("Problem Adding a Plane to a hash
table");
}
System.out.println("Airplane was successfully added");
}
}
Thanks tuurbo