Design a graphic that would show a car parking into a parking slot in a parking
ID: 3802575 • Letter: D
Question
Design a graphic that would show a car parking into a parking slot in a parking lot of at least 14 parking slots. Please park your car after driving past half way of the drive way.
Layout of the parking lot should be 90 degree two way. Check the reference for some information on the specifications for your background knowledge. Design your car (rectangular shape) to the size of 80% length and 80% width of your parking spot.
You are expected to work on this assignment in class on Feb 27th. Upload code and screenshots. Need to demonstrate in class.
Reference on Parking Lot Specifications: http://www.uh.edu/facilities-services/departments/fpc/design-guidelines/09_parking.pdf (Links to an external site.) (Links to an external site.)
Explanation / Answer
public class ParkingSlot
{
Vector<ParkingLot> vacantParkingLots = null;
Vector<ParkingLot> fullParkingLots = null;
int parkingLotCount = 0;
boolean isFull;
boolean isEmpty;
ParkingLot findNearestVacant(ParkingType type)
{
Iterator<ParkingLot> itr = vacantParkingLots.iterator();
while(itr.hasNext())
{
ParkingLot parkingLot = itr.next();
if(parkingLot.parkingType == type)
{
return parkingLot;
}
}
return null;
}
void parkCar(ParkingType type, Car Car)
{
if(!isFull())
{
ParkingLot parkingLot = findNearestVacant(type);
if(parkingLot != null)
{
parkingLot.Car = Car;
parkingLot.isVacant = false;
vacantParkingLots.remove(parkingLot);
fullParkingLots.add(parkingLot);
if(fullParkingLots.size() == parkingLotCount)
isFull = true;
isEmpty = false;
}
}
}
void releaseCar(Car Car)
{
if(!isEmpty())
{
Iterator<ParkingLot> itr = fullParkingLots.iterator();
while(itr.hasNext())
{
ParkingLot parkingLot = itr.next();
if(parkingLot.Car.equals(Car))
{
fullParkingLots.remove(parkingLot);
vacantParkingLots.add(parkingLot);
parkingLot.isVacant = true;
parkingLot.Car = null;
if(vacantParkingLots.size() == parkingLotCount)
isEmpty = true;
isFull = false;
}
}
}
}
boolean isFull()
{
return isFull;
}
boolean isEmpty()
{
return isEmpty;
}
}
public class ParkingLot
{
boolean isVacant;
Car Car;
ParkingType parkingType;
int distance;
}
public class Car
{
int num;
}
public enum ParkingType
{
REGULAR,
HANDICAPPED,
COMPACT,
MAX_PARKING_TYPE,
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.