In: Computer Science
(must be done in JAVA code)
A company dedicated to parking management has decided to renew itself by automating its control process since this process is done manually. The company has hired its development team to automate the process and gave it an October 19th deadline until 6 pm. An analyst defined the system requirements as follows:
1. The system must allow configuring the number of spaces that a vehicle parking lot will contain.
2. The system must allow the person in charge (normally a security person) to consult the available spaces to be able to indicate to the arriving users where to park.
3. The system must allow the person in charge (normally a security person) to enter the space where they will park, the license plate, brand, color and commercial value of the vehicle to be parked. In some cases, the person in charge may omit the commercial value of the vehicle due to ignorance, for these cases a default value of 30 million will be saved.
4. The system must allow the status of all the spaces in the building to be consulted.
5. The system must allow printing all the information of the parked vehicles.
6. The system must allow consulting the information of a parked vehicle.
7. The system must be able to change the sensor status (available to occupied) when a car occupies a parking space.
Hope this will help you, Please Thumbs Up , Thanks in advance!
*************************************************************************
Vehicle.java
public class Vehicle {
private int vehicleId;
private String brand;
private String color;
private int vehicleValue=10;
public String getBrand() {
return brand;
}
public int getVehicleId() {
return vehicleId;
}
public void setVehicleId(int vehicleId) {
this.vehicleId = vehicleId;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getVehicleValue() {
return vehicleValue;
}
public void setVehicleValue(int vehicleValue) {
this.vehicleValue = vehicleValue;
}
public Vehicle(String brand, String color, int vehicleValue,int
vehickeId) {
super();
this.brand = brand;
this.color = color;
this.vehicleValue = vehicleValue;
this.vehicleId=vehickeId;
}
@Override
public String toString() {
return "Vehicle [vehicleId=" + vehicleId + ", brand="
+ brand + ", color=" + color + ", vehicleValue="
+ vehicleValue +
"]";
}
}
************************************************************************
ParkingSlot.java
public class ParkingSlot {
private int slotId;
private String slotStatus="A"; //status =A means slot available and
status=NA means slot not available
private Vehicle vehicle;
public int getSlotId() {
return slotId;
}
public void setSlotId(int slotId) {
this.slotId = slotId;
}
public String getSlotStatus() {
return slotStatus;
}
public void setSlotStatus(String slotStatus) {
this.slotStatus = slotStatus;
}
public Vehicle getV() {
return vehicle;
}
public void setV(Vehicle v) {
this.vehicle = v;
}
}
********************************************************************
Parking.java
public class Parking {
private ParkingSlot[] AllSlots=new ParkingSlot[10]; //configuring
number of slots that parking will contain to 10
public Parking()
{
for(int i=0;i<10;i++)
{
ParkingSlot ps=new
ParkingSlot();
ps.setSlotId(i);
ps.setSlotStatus("Available");
ps.setV(null);
AllSlots[i]=ps;
}
}
public void ViewAllParkingSlots()
{
System.out.println("Status of slots
availability");
for(int i=0;i<10 ;i++)
{
System.out.println(AllSlots[i].getSlotId()+"--->"+AllSlots[i].getSlotStatus());
}
}
public void ViewOccupiedParkingSlots()
{
for(int i=0;i<10;i++)
{
if(AllSlots[i].getV()!=null
&& AllSlots[i].getSlotStatus().equalsIgnoreCase("Occupied")
)
{
System.out.println("slot id"+AllSlots[i].getSlotId());
System.out.println("vehicle informtion:");
System.out.println("Vehicle
id:"+AllSlots[i].getV().getVehicleId());
System.out.println("Vehicle
Brand:"+AllSlots[i].getV().getBrand());
System.out.println("Vehicle
Color:"+AllSlots[i].getV().getColor());
System.out.println("Vehicle Value in
million:"+AllSlots[i].getV().getVehicleValue());
}
}
}
public void ParkVehicle(Vehicle v,int slotId)
{
AllSlots[slotId].setSlotStatus("Occupied");
AllSlots[slotId].setV(v);
}
}
************************************************************************
Test.java
import java.util.*;
import java.io.*;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method
stub
int WantToPark =0;
Scanner sc=new
Scanner(System.in);
Parking p=new Parking();
System.out.println("***********************************************");
p.ViewAllParkingSlots();
System.out.println("***********************************************");
do
{
System.out.println("Do you want to park vehicle if yes please enter
1 else 0");
WantToPark=sc.nextInt();
if(WantToPark==1)
{
System.out.println("Please select
slot and enter slot id:");
int sid=sc.nextInt();
System.out.println("Please Vehicle
details...");
System.out.println("Enter vehicle
id:");
int vid=sc.nextInt();
sc.nextLine();
System.out.println("Enter vehicle
brand:");
String brand=sc.nextLine();
System.out.println("Enter vehicle
color:");
String color=sc.nextLine();
System.out.println("Enter vehicle
values:");
int value=sc.nextInt();
Vehicle v=new Vehicle(brand,
color,value, vid);
p.ParkVehicle(v,sid);
System.out.println("***********************************************");
System.out.println("All slots of
parking");
p.ViewAllParkingSlots();
System.out.println("***********************************************");
System.out.println("Occupied slots
of parking");
p.ViewOccupiedParkingSlots();
System.out.println("***********************************************");
}
}while(WantToPark==1);
}
}
*****************************************************************************S
Screen shot of output