Final Project Write a C program to manage a parking lot Buil

Final Project: Write a C++ program to manage a parking lot. Build Specifications 1. The parking lot has multiple levels. Each level has multiple rows of spots. 2. The parking lot can park motorcycles, cars, and buses 3. The parking lot has motorcycle spots, compact spots, and large spots. 4. A motorcycle can park in any spot. 5. A car can park in either a single compact spot or a single large spot. 6. A bus can park in five large spots that are consecutive and within the same row. It cannot park in small spots.

Solution

public class ParkingLot
{
Vector<Parkingspace> vacantParkingSpaces = null;
Vector<ParkingSpace> fullParkingSpaces = null;

int parkingSpaceCount = 0;

boolean isFull;
boolean isEmpty;

ParkingSpace findNearestVacant(ParkingType type)
{
Iterator<ParkingSpace> itr = vacantParkingSpaces.iterator();

while(itr.hasNext())
{
ParkingSpace parkingSpace = itr.next();

if(parkingSpace.parkingType == type)
{
return parkingSpace;
}
}
return null;
}

void parkVehicle(ParkingType type, Vehicle vehicle)
{
if(!isFull())
{
ParkingSpace parkingSpace = findNearestVacant(type);

if(parkingSpace != null)
{
parkingSpace.vehicle = vehicle;
parkingSpace.isVacant = false;

vacantParkingSpaces.remove(parkingSpace);
fullParkingSpaces.add(parkingSpace);

if(fullParkingSpaces.size() == parkingSpaceCount)
isFull = true;

isEmpty = false;
}
}
}

void releaseVehicle(Vehicle vehicle)
{
if(!isEmpty())
{
Iterator<ParkingSpace> itr = fullParkingSpaces.iterator();

while(itr.hasNext())
{
ParkingSpace parkingSpace = itr.next();

if(parkingSpace.vehicle.equals(vehicle))
{
fullParkingSpaces.remove(parkingSpace);
vacantParkingSpaces.add(parkingSpace);

parkingSpace.isVacant = true;
parkingSpace.vehicle = null;

if(vacantParkingSpaces.size() == parkingSpaceCount)
isEmpty = true;

isFull = false;
}
}
}
}

boolean isFull()
{
return isFull;
}

boolean isEmpty()
{
return isEmpty;
}
}

public class ParkingSpace
{
boolean isVacant;
Vehicle vehicle;
ParkingType parkingType;
int distance;
}

public class Vehicle
{
int num;
}

public enum ParkingType
{
   motorcycle_spot,
  
compact_spot,
large_spot,
}

class ParkingLot
{
Space[][] spaces;

ParkingLot(wide, long); // constructor

FindOpenSpace(TypeOfvehicle); // find first open space where type matches
}

enum TypeOfSpace = {motorcycle_spot,compact_spot,large_spot };
enum TypeOfvehicle = {motorcycle,cars,buses };

class Space
{
TypeOfSpace type;
bool empty;
// gets and sets here
// make sure vehicle type
}

class vehicle
{
TypeOfvehicle type;
}
void main()
{
cout<<\"enter choice\ \";
cout<<\"1.setup the parking lot\ \";
cout<<\"2.edit\ \";
cout<<\"3.look for capacity\\\";
cout<<\"4.view level information\ \"
cout<<\"5.exit\";
cin>>&n


using switch case we call appropraite operations whatever we required..

thank you

 Final Project: Write a C++ program to manage a parking lot. Build Specifications 1. The parking lot has multiple levels. Each level has multiple rows of spots.
 Final Project: Write a C++ program to manage a parking lot. Build Specifications 1. The parking lot has multiple levels. Each level has multiple rows of spots.
 Final Project: Write a C++ program to manage a parking lot. Build Specifications 1. The parking lot has multiple levels. Each level has multiple rows of spots.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site