Problem with case - might need recursion
Hey this is my 1st thread
I have this class
Code:
class Vehicle {
private int Aukswn; //Number of cars entered the parking area
private String Pinakida; //The cars license plate number
private String Type; // Car type
private int Position; //The position the car is going to park
public Vehicle() {
Aukswn = 0;
Pinakida = new String();
Type = new String();
Position = 0;
}
public void Vehicle (int Aukswn, String Pinakida, String Type, int Position) {
this.Aukswn = Aukswn;
this.Pinakida = Pinakida;
this.Type = Type;
this.Position = Position;
}
public int getAukswn() {
return this.Aukswn;
}
public String getPinakida() {
return this.Pinakida;
}
public String getType() {
return this.Type;
}
public int getPosition() {
return this.Position;
}
}
Code:
public class Main {
public static void main (String args[]) {
int i, choice;
Vehicle array[] = new Vehicle[10];
do{
System.out.print("Main menu");
System.out.print("1. Arrival of Vehicle");
System.out.print("2. Vehicle Properties");
System.out.print("3. Free parking slots");
System.out.print("4. End");
System.out.print("Choice (1-4) :");
choice = UserInput.getInteger();
switch (choice) {
case (1):
}
}
while (choice == 4);
}
}
Now I find it a bit complicated to explain in English but I will try
For the 1st case, I will need to
Send a message to the user that there are any free parking slots (variable position = 0),and if there are, display the index of the first free slot to the user (else it will send him back to the main menu)
If there is a free parking slot, the user should enter the properties of the vehicle (I have my Insert class for that purpose, but for some reason I cant use it under a case)
Code:
public void Insert() {
System.out.print ("Give the number of cars entered the parking area");
this.Aukswn = UserInput.getInteger();
System.out.print ("Give the car's license plate number");
this.Pinakida = UserInput.getString();
System.out.print ("Give the parking slot which the car entered");
this.Position = UserInput.getInteger();
System.out.print ("Give the type of the car");
this.Type = UserInput.getString();
}
The position the user enters should be the one the program displayed at him
If he does not enter this position, or an invalid number (e.g. > 10) it should return him to the main menu
After the user succesfully enters the mentioned properties of the vehicle, the program returns him to the main menu. It should also return him if he presses the Esc. button during entering them
Any opinions?