Design and Implementation of a Multi-story Car-Parking Program (MCP)
VerifiedAdded on  2023/06/10
|19
|5111
|491
Project
AI Summary
This document provides a comprehensive solution to a multi-story car-parking program (MCP) assignment. The project involves designing and implementing a prototype car parking system with features like driver registration, vehicle type selection, and parking space allocation. The solution includes class diagrams, use case diagrams, and a test table to demonstrate the system's functionality. The core components include classes for attendants, drivers, vehicles, zones, spaces, and receipts, along with a main class (MCP) that handles user interaction via a command-line menu. Key functionalities include finding parking spaces, generating receipts with arrival and exit times, calculating parking fees, and managing disabled driver accommodations. The code outlines the classes, methods, and data structures used to model the car parking system's various aspects, including data loading, space availability, and user payment processing. The system also provides functionalities for attendants to assist drivers, which impacts the user's experience.

COVER PAGE
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

Contents
1 problem analysis.......................................................................................................................................3
A. Potential classes and their objects......................................................................................................3
B. Use case diagram.................................................................................................................................4
2 Class diagram............................................................................................................................................5
3 Test table..................................................................................................................................................5
4 outline classes..........................................................................................................................................6
5 Evaluation...............................................................................................................................................19
Figure 1:Use case diagram...........................................................................................................................4
Figure 2:class diagram.................................................................................................................................5
1 problem analysis.......................................................................................................................................3
A. Potential classes and their objects......................................................................................................3
B. Use case diagram.................................................................................................................................4
2 Class diagram............................................................................................................................................5
3 Test table..................................................................................................................................................5
4 outline classes..........................................................................................................................................6
5 Evaluation...............................................................................................................................................19
Figure 1:Use case diagram...........................................................................................................................4
Figure 2:class diagram.................................................................................................................................5

1 problem analysis
A. Potential classes and their objects
After evaluating the problem statement, the classes making up the proposed system and their potential
objects were identified. These classes are;
ï‚· Attendant class
This class consists of the accessor and mutator objects for an attendant. An attendant will have
an attendant ID, name and availability status thus each of these attributes will have an accessor
and mutator object.
ï‚· Driver class
This class consists of the accessor and mutator objects for a driver. A driver will be identified by
their license plate number thus the driver class will have the accessor and mutator methods for
its attributes. Another possible class which will inherit all the properties of the driver class is the
Disabled driver class. A disabled driver will have all the properties of a driver and that is why
inheritance is suitable between the two classes.
ï‚· Zone class
A zone is made up of spaces thus it’s an aggregate of many spaces. The zone class will have
different attributes including the zone ID, the zone type, a list of vehicles the zone can
accommodate and a list of spaces it’s made up of. Each of these attributes will have an accessor
and mutator method which will make up the zone class.
ï‚· Space class
A zone is made up of many spaces. Each space is identified by its space ID and its availability.
The space class will have contain the accessor and mutator methods for each of the attribute
identifying the space class.
ï‚· Vehicle class
The vehicle class will be identified by the type and the rate that the each type of vehicle is
charged per hour. Each of the attributes identifying the vehicle class will have an accessor and
mutator method.
ï‚· Loader class
This class will be used to load data into the data structures defined for the program. The class
will have an object to read a text file and another object to interpret the data read from the text
file and put in a list.
ï‚· MCP class
This class will contain the main method and will be used to instantiate different classes and
methods for the program to run. All the objects will be created using this class. It will also
contain a menu class which will help the user to interact with the program.
ï‚· Receipt class
The receipt class will be used to identify a certain parking session. Thus the attributes identifying
the class will include the receipt NO which will act as the token, the space the vehicle was
parked, the zone that the space is in, the driver of the vehicle, the attendant who attended to
the vehicle if any, the arrival time of the driver and the exit time of the driver. Each of these
attributes will have an accessor and a mutator record.
A. Potential classes and their objects
After evaluating the problem statement, the classes making up the proposed system and their potential
objects were identified. These classes are;
ï‚· Attendant class
This class consists of the accessor and mutator objects for an attendant. An attendant will have
an attendant ID, name and availability status thus each of these attributes will have an accessor
and mutator object.
ï‚· Driver class
This class consists of the accessor and mutator objects for a driver. A driver will be identified by
their license plate number thus the driver class will have the accessor and mutator methods for
its attributes. Another possible class which will inherit all the properties of the driver class is the
Disabled driver class. A disabled driver will have all the properties of a driver and that is why
inheritance is suitable between the two classes.
ï‚· Zone class
A zone is made up of spaces thus it’s an aggregate of many spaces. The zone class will have
different attributes including the zone ID, the zone type, a list of vehicles the zone can
accommodate and a list of spaces it’s made up of. Each of these attributes will have an accessor
and mutator method which will make up the zone class.
ï‚· Space class
A zone is made up of many spaces. Each space is identified by its space ID and its availability.
The space class will have contain the accessor and mutator methods for each of the attribute
identifying the space class.
ï‚· Vehicle class
The vehicle class will be identified by the type and the rate that the each type of vehicle is
charged per hour. Each of the attributes identifying the vehicle class will have an accessor and
mutator method.
ï‚· Loader class
This class will be used to load data into the data structures defined for the program. The class
will have an object to read a text file and another object to interpret the data read from the text
file and put in a list.
ï‚· MCP class
This class will contain the main method and will be used to instantiate different classes and
methods for the program to run. All the objects will be created using this class. It will also
contain a menu class which will help the user to interact with the program.
ï‚· Receipt class
The receipt class will be used to identify a certain parking session. Thus the attributes identifying
the class will include the receipt NO which will act as the token, the space the vehicle was
parked, the zone that the space is in, the driver of the vehicle, the attendant who attended to
the vehicle if any, the arrival time of the driver and the exit time of the driver. Each of these
attributes will have an accessor and a mutator record.
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

B. Use case diagram
After evaluating the possible functions and operations of the proposed system, the following is the use
case diagram. It has two actors; a driver and an attendant. An attendant will is supposed to attend to the
driver, thus he or she can perform all the actions of the driver within the system.
Figure 1:Use case diagram
After evaluating the possible functions and operations of the proposed system, the following is the use
case diagram. It has two actors; a driver and an attendant. An attendant will is supposed to attend to the
driver, thus he or she can perform all the actions of the driver within the system.
Figure 1:Use case diagram
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

2 Class diagram
Figure 2:class diagram
The following diagram shows the possible implementation of the proposed system. Each class has been
represented with its objects and attributes. Some methods might be added as the system is
implemented.
3 Test table
ID Requirement Description Inputs Expected outputs Pass/
Fail
Comments
A1.1 FR12 Find parking
licensePlate of
vehicle
Enter 32-
3sfd
Screen shot SS1 is
displayed
P License plate
number is accepted
Enter 23-
3sdf
Screen shot SS2 is
displayed
P License plate
number is accepted
Enter Enter Screen shot SS3 is F License plate is
Figure 2:class diagram
The following diagram shows the possible implementation of the proposed system. Each class has been
represented with its objects and attributes. Some methods might be added as the system is
implemented.
3 Test table
ID Requirement Description Inputs Expected outputs Pass/
Fail
Comments
A1.1 FR12 Find parking
licensePlate of
vehicle
Enter 32-
3sfd
Screen shot SS1 is
displayed
P License plate
number is accepted
Enter 23-
3sdf
Screen shot SS2 is
displayed
P License plate
number is accepted
Enter Enter Screen shot SS3 is F License plate is

32-32assad displayed accepted
A1.2 FR13 Selecting menu
option
Select 1 Screen shot SS4 is
displayed
F
Select d Screen shot SS5 is
displayed
P A
NumberFormatExce
ption
Exception was
thrown
4 outline classes
ï‚· Attendant
public class Attendant {
private int attendantID;
private String name;
private boolean availability;
public Attendant(){}
public void setAttendantID(int attID){
this.attendantID=attID;
}
public int getAttendantID(){
return this.attendantID;
}
public void setName(String attName){
this.name=attName;
}
public String getName(){
return this.name;
}
public String toString(){
return this.name+" - :"+attendantID;
}
public void setAvailability(boolean status){
this.availability=status;
}
public boolean getAvailability(){
return this.availability;
}
}
ï‚· Driver
ï‚· public class Driver {
private String licensePlate;
public Driver(){}
public void setlicensePlate(String plateNumber){
this.licensePlate=plateNumber;
}
public String getLicensePlate(){
A1.2 FR13 Selecting menu
option
Select 1 Screen shot SS4 is
displayed
F
Select d Screen shot SS5 is
displayed
P A
NumberFormatExce
ption
Exception was
thrown
4 outline classes
ï‚· Attendant
public class Attendant {
private int attendantID;
private String name;
private boolean availability;
public Attendant(){}
public void setAttendantID(int attID){
this.attendantID=attID;
}
public int getAttendantID(){
return this.attendantID;
}
public void setName(String attName){
this.name=attName;
}
public String getName(){
return this.name;
}
public String toString(){
return this.name+" - :"+attendantID;
}
public void setAvailability(boolean status){
this.availability=status;
}
public boolean getAvailability(){
return this.availability;
}
}
ï‚· Driver
ï‚· public class Driver {
private String licensePlate;
public Driver(){}
public void setlicensePlate(String plateNumber){
this.licensePlate=plateNumber;
}
public String getLicensePlate(){
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

return this.licensePlate;
}
}
ï‚· DisabledDriver
public class DisabledDriver extends Driver {
private boolean status;
public DisabledDriver(){}
public void setStatus(boolean status){
this.status=status;
}
public boolean getStatus(){
return this.status;
}
}
ï‚· Loader
ï‚· import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
public class Loader {
public Loader(){}
private String [] readFile(String filename) throws IOException {
BufferedReader br=null;
try{
br=new BufferedReader(new FileReader(filename));
StringBuilder sb=new StringBuilder();
String line=br.readLine();
while(line!=null){
sb.append(line);
sb.append("\n");
line=br.readLine();
}
String everything=sb.toString();
String [] blocks=everything.split("\n");
return blocks;
}catch (Exception e){
e.printStackTrace();
return null;
}finally{
br.close();
}
}
public ArrayList populateData(String filename) throws IOException{
ArrayList<ArrayList> data=new ArrayList<>();
String arr[]=readFile(filename);
for (int i=0;i<arr.length;i++){
String[] details=arr[i].split("~");
ArrayList<String> datum=new ArrayList<String>();
for (int j=0;j<details.length;j++){
datum.add(details[j]);
}
data.add(datum);
}
}
ï‚· DisabledDriver
public class DisabledDriver extends Driver {
private boolean status;
public DisabledDriver(){}
public void setStatus(boolean status){
this.status=status;
}
public boolean getStatus(){
return this.status;
}
}
ï‚· Loader
ï‚· import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
public class Loader {
public Loader(){}
private String [] readFile(String filename) throws IOException {
BufferedReader br=null;
try{
br=new BufferedReader(new FileReader(filename));
StringBuilder sb=new StringBuilder();
String line=br.readLine();
while(line!=null){
sb.append(line);
sb.append("\n");
line=br.readLine();
}
String everything=sb.toString();
String [] blocks=everything.split("\n");
return blocks;
}catch (Exception e){
e.printStackTrace();
return null;
}finally{
br.close();
}
}
public ArrayList populateData(String filename) throws IOException{
ArrayList<ArrayList> data=new ArrayList<>();
String arr[]=readFile(filename);
for (int i=0;i<arr.length;i++){
String[] details=arr[i].split("~");
ArrayList<String> datum=new ArrayList<String>();
for (int j=0;j<details.length;j++){
datum.add(details[j]);
}
data.add(datum);
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

}
return data;
}
}
ï‚· Receipt
public class Receipt {
private String receiptNO;
private Space space;
private String arrivalTime;
private String exitTime;
private DisabledDriver driver;
private double amount;
private Zone zone;
private Attendant attendant;
private Vehicle userVehicle;
public Receipt(){
this.attendant=null;
this.exitTime="000000";
}
public void setReceiptNO(String receiptno){
this.receiptNO=receiptno;
}
public String getReceiptNO(){
return this.receiptNO;
}
public void setSpace(Space space){
this.space=space;
}
public Space getSpace(){
return this.space;
}
public void setArrivalTime(String arrivaltime){
this.arrivalTime=arrivaltime;
}
public String getArrivalTime(){
return this.arrivalTime;
}
public void seExitTime(String exittime){
this.exitTime=exittime;
}
public String getExitTime(){
return this.exitTime;
}
public void setDriver(DisabledDriver dr){
this.driver=dr;
}
public Driver getDriver(){
return this.driver;
}
public void setAttendant(Attendant att){
this.attendant=att;
}
public void setAmount(double amt){
this.amount=amt;
}
public double getAmount(){
return this.amount;
}
public void setUserVehicle(Vehicle vehicle){
return data;
}
}
ï‚· Receipt
public class Receipt {
private String receiptNO;
private Space space;
private String arrivalTime;
private String exitTime;
private DisabledDriver driver;
private double amount;
private Zone zone;
private Attendant attendant;
private Vehicle userVehicle;
public Receipt(){
this.attendant=null;
this.exitTime="000000";
}
public void setReceiptNO(String receiptno){
this.receiptNO=receiptno;
}
public String getReceiptNO(){
return this.receiptNO;
}
public void setSpace(Space space){
this.space=space;
}
public Space getSpace(){
return this.space;
}
public void setArrivalTime(String arrivaltime){
this.arrivalTime=arrivaltime;
}
public String getArrivalTime(){
return this.arrivalTime;
}
public void seExitTime(String exittime){
this.exitTime=exittime;
}
public String getExitTime(){
return this.exitTime;
}
public void setDriver(DisabledDriver dr){
this.driver=dr;
}
public Driver getDriver(){
return this.driver;
}
public void setAttendant(Attendant att){
this.attendant=att;
}
public void setAmount(double amt){
this.amount=amt;
}
public double getAmount(){
return this.amount;
}
public void setUserVehicle(Vehicle vehicle){

this.userVehicle=vehicle;
}
public Vehicle getUserVehicle(){
return this.userVehicle;
}
public void setZone(Zone zone){
this.zone=zone;
}
public Zone getZone(){
return this.zone;
}
public void displayReceipt(){
System.out.println("***************************Parking
Receipt***********************");
System.out.println("Receipt NO: "+receiptNO);
System.out.println("Vehicle License plate: "+driver.getLicensePlate());
System.out.println("Disability : "+driver.getStatus());
System.out.println("Arrival Time: "+getTime(arrivalTime));
System.out.println("Exit time: "+getTime(exitTime));
System.out.println("Amount: "+amount);
System.out.println("**************Your allocated space
is****************************");
System.out.println("ZoneID :"+zone.getZoneID()+" ("+zone.getType()+")");
System.out.println("Space: "+space.getSpaceID());
System.out.println("Serverd by: "+attendant.getName());
System.out.println("Thank you for choosing MCP");
}
public String getTime(String time){
long millis = Long.parseLong(time) % 1000;
long second = (Long.parseLong(time) / 1000) % 60;
long minute = (Long.parseLong(time) / (1000 * 60)) % 60;
long hour = (Long.parseLong(time) / (1000 * 60 * 60)) % 24;
String timeFormat = String.format("%02d:%02d:%02d.%d", hour, minute, second,
millis);
return timeFormat;
}
}
ï‚· Space
ï‚· public class Space {
private int spaceID;
private boolean avaialability;
public Space(){}
public void setSpaceID(int spaceNO){
this.spaceID=spaceNO;
}
public int getSpaceID(){
return this.spaceID;
}
public void setAvaialability(boolean status){
this.avaialability=status;
}
public boolean getAvailability(){
return this.avaialability;
}
public String toString(){
return this.spaceID+" : "+this.avaialability;
}
}
}
public Vehicle getUserVehicle(){
return this.userVehicle;
}
public void setZone(Zone zone){
this.zone=zone;
}
public Zone getZone(){
return this.zone;
}
public void displayReceipt(){
System.out.println("***************************Parking
Receipt***********************");
System.out.println("Receipt NO: "+receiptNO);
System.out.println("Vehicle License plate: "+driver.getLicensePlate());
System.out.println("Disability : "+driver.getStatus());
System.out.println("Arrival Time: "+getTime(arrivalTime));
System.out.println("Exit time: "+getTime(exitTime));
System.out.println("Amount: "+amount);
System.out.println("**************Your allocated space
is****************************");
System.out.println("ZoneID :"+zone.getZoneID()+" ("+zone.getType()+")");
System.out.println("Space: "+space.getSpaceID());
System.out.println("Serverd by: "+attendant.getName());
System.out.println("Thank you for choosing MCP");
}
public String getTime(String time){
long millis = Long.parseLong(time) % 1000;
long second = (Long.parseLong(time) / 1000) % 60;
long minute = (Long.parseLong(time) / (1000 * 60)) % 60;
long hour = (Long.parseLong(time) / (1000 * 60 * 60)) % 24;
String timeFormat = String.format("%02d:%02d:%02d.%d", hour, minute, second,
millis);
return timeFormat;
}
}
ï‚· Space
ï‚· public class Space {
private int spaceID;
private boolean avaialability;
public Space(){}
public void setSpaceID(int spaceNO){
this.spaceID=spaceNO;
}
public int getSpaceID(){
return this.spaceID;
}
public void setAvaialability(boolean status){
this.avaialability=status;
}
public boolean getAvailability(){
return this.avaialability;
}
public String toString(){
return this.spaceID+" : "+this.avaialability;
}
}
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

ï‚· Vehicle
public class Vehicle {
private int vehicleID;
private String type;
private double rate;
public Vehicle (){}
public void setVehicleID(int vID){
this.vehicleID=vID;
}
public int getVehicleID(){
return this.vehicleID;
}
public void setType(String vType){
this.type=vType;
}
public String getType(){
return this.type;
}
public void setRate(double vRate){
this.rate=vRate;
}
public double getRate(){
return this.rate;
}
}
ï‚· Zone
ï‚· import java.util.ArrayList;
public class Zone {
private int zoneID;
private String type;
private ArrayList<Vehicle> vehicles;
private ArrayList<Space> spaces;
public Zone(){
vehicles=new ArrayList<>();
spaces=new ArrayList<>();
}
public void setZoneID(int zoneNO){
this.zoneID=zoneNO;
}
public int getZoneID(){
return this.zoneID;
}
public void setType(String zoneType){
this.type=zoneType;
}
public String getType(){
return this.type;
}
public void setVehicles(Vehicle vehicle){
this.vehicles.add(vehicle);
}
public ArrayList getVehicles(){
return this.vehicles;
}
public class Vehicle {
private int vehicleID;
private String type;
private double rate;
public Vehicle (){}
public void setVehicleID(int vID){
this.vehicleID=vID;
}
public int getVehicleID(){
return this.vehicleID;
}
public void setType(String vType){
this.type=vType;
}
public String getType(){
return this.type;
}
public void setRate(double vRate){
this.rate=vRate;
}
public double getRate(){
return this.rate;
}
}
ï‚· Zone
ï‚· import java.util.ArrayList;
public class Zone {
private int zoneID;
private String type;
private ArrayList<Vehicle> vehicles;
private ArrayList<Space> spaces;
public Zone(){
vehicles=new ArrayList<>();
spaces=new ArrayList<>();
}
public void setZoneID(int zoneNO){
this.zoneID=zoneNO;
}
public int getZoneID(){
return this.zoneID;
}
public void setType(String zoneType){
this.type=zoneType;
}
public String getType(){
return this.type;
}
public void setVehicles(Vehicle vehicle){
this.vehicles.add(vehicle);
}
public ArrayList getVehicles(){
return this.vehicles;
}
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

public ArrayList getSpaces(){
return this.spaces;
}
public void setSpaces(Space space){
this.spaces.add(space);
}
}
ï‚· MCP
ï‚· import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class MCP {
private ArrayList<Vehicle> vehicleData=new ArrayList<>();
private ArrayList<Zone> zoneData=new ArrayList<>();
private ArrayList<Attendant> attendantData=new ArrayList<>();
private ArrayList<Receipt> receipts=new ArrayList<>();
public MCP(){
}
public static void main(String[] args) throws IOException {
System.out.println("Welcome to MCP parking");
MCP mcp=new MCP();
mcp.startup();
mcp.menu();
}
public void menu(){
System.out.println("*********************MENU*************");
Scanner s=new Scanner(System.in);
System.out.println("1 Find Parking");
System.out.println("2 Exit parking");
try {
int option = s.nextInt();
if(option==1){
findParking();
}else if(option==2){
exitParking();
}else{
System.out.println("Invalid option");
menu();
}
}catch(NumberFormatException e){
System.out.println("Use numbers only specified in the menu only");
}
}
public void findParking(){
System.out.println("Do you want to be assisted by an attendant? (Y=yes,
N=No");
Scanner s=new Scanner(System.in);
String option=s.next();
if(option.equalsIgnoreCase("y")){
Random random=new Random();
int randomNumber = random.nextInt(attendantData.size() - 1) + 1;
return this.spaces;
}
public void setSpaces(Space space){
this.spaces.add(space);
}
}
ï‚· MCP
ï‚· import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class MCP {
private ArrayList<Vehicle> vehicleData=new ArrayList<>();
private ArrayList<Zone> zoneData=new ArrayList<>();
private ArrayList<Attendant> attendantData=new ArrayList<>();
private ArrayList<Receipt> receipts=new ArrayList<>();
public MCP(){
}
public static void main(String[] args) throws IOException {
System.out.println("Welcome to MCP parking");
MCP mcp=new MCP();
mcp.startup();
mcp.menu();
}
public void menu(){
System.out.println("*********************MENU*************");
Scanner s=new Scanner(System.in);
System.out.println("1 Find Parking");
System.out.println("2 Exit parking");
try {
int option = s.nextInt();
if(option==1){
findParking();
}else if(option==2){
exitParking();
}else{
System.out.println("Invalid option");
menu();
}
}catch(NumberFormatException e){
System.out.println("Use numbers only specified in the menu only");
}
}
public void findParking(){
System.out.println("Do you want to be assisted by an attendant? (Y=yes,
N=No");
Scanner s=new Scanner(System.in);
String option=s.next();
if(option.equalsIgnoreCase("y")){
Random random=new Random();
int randomNumber = random.nextInt(attendantData.size() - 1) + 1;

Attendant attendant=attendantData.get(randomNumber);
parkVehicle(attendant);
}else if(option.equalsIgnoreCase("n")){
//no attendant
parkVehicle();
}else{
System.out.println("Invalid option");
findParking();
}
}
public void parkVehicle(){
Scanner s=new Scanner(System.in);
System.out.println("Enter the license plate of the vehicle");
String licensePlate=s.next();
System.out.println("Do you have any disability? (Y=Yes, N=No");
String option=s.next();
boolean opt=false;
if(option.equalsIgnoreCase("y")){
opt=true;
}else if(option.equalsIgnoreCase("n")){
opt=false;
}else{
System.out.println("Invalid option");
System.out.println("Do you have any disability? (Y=Yes, N=No");
option=s.next();
if(option.equalsIgnoreCase("y")){
opt=true;
}else if(option.equalsIgnoreCase("n")){
opt=false;
}
}
DisabledDriver driver=new DisabledDriver();
driver.setlicensePlate(licensePlate);
driver.setStatus(opt);
System.out.println("Select you vehicle type");
Vehicle driverVehicle=null;
for(int i=0;i<vehicleData.size();i++){
System.out.println(i+" "+vehicleData.get(i).getType());
}
int selectedVehicle;
try {
selectedVehicle = s.nextInt();
if (selectedVehicle>=0 && selectedVehicle<=vehicleData.size()){
driverVehicle=vehicleData.get(selectedVehicle);
}else{
System.out.println("Invalid option Select vehicle");
for(int i=0;i<vehicleData.size();i++){
System.out.println(i+" "+vehicleData.get(i).getType());
}
selectedVehicle = s.nextInt();
if (selectedVehicle>=0 && selectedVehicle<=vehicleData.size()){
driverVehicle=vehicleData.get(selectedVehicle);
}else{
System.out.println("Invalid option Select vehicle");
for(int i=0;i<vehicleData.size();i++){
parkVehicle(attendant);
}else if(option.equalsIgnoreCase("n")){
//no attendant
parkVehicle();
}else{
System.out.println("Invalid option");
findParking();
}
}
public void parkVehicle(){
Scanner s=new Scanner(System.in);
System.out.println("Enter the license plate of the vehicle");
String licensePlate=s.next();
System.out.println("Do you have any disability? (Y=Yes, N=No");
String option=s.next();
boolean opt=false;
if(option.equalsIgnoreCase("y")){
opt=true;
}else if(option.equalsIgnoreCase("n")){
opt=false;
}else{
System.out.println("Invalid option");
System.out.println("Do you have any disability? (Y=Yes, N=No");
option=s.next();
if(option.equalsIgnoreCase("y")){
opt=true;
}else if(option.equalsIgnoreCase("n")){
opt=false;
}
}
DisabledDriver driver=new DisabledDriver();
driver.setlicensePlate(licensePlate);
driver.setStatus(opt);
System.out.println("Select you vehicle type");
Vehicle driverVehicle=null;
for(int i=0;i<vehicleData.size();i++){
System.out.println(i+" "+vehicleData.get(i).getType());
}
int selectedVehicle;
try {
selectedVehicle = s.nextInt();
if (selectedVehicle>=0 && selectedVehicle<=vehicleData.size()){
driverVehicle=vehicleData.get(selectedVehicle);
}else{
System.out.println("Invalid option Select vehicle");
for(int i=0;i<vehicleData.size();i++){
System.out.println(i+" "+vehicleData.get(i).getType());
}
selectedVehicle = s.nextInt();
if (selectedVehicle>=0 && selectedVehicle<=vehicleData.size()){
driverVehicle=vehicleData.get(selectedVehicle);
}else{
System.out.println("Invalid option Select vehicle");
for(int i=0;i<vehicleData.size();i++){
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide
1 out of 19
Related Documents

Your All-in-One AI-Powered Toolkit for Academic Success.
 +13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.