Designing a Parking Management System: Classes and Use Case Diagram
Verified
Added on  2023/06/10
|19
|5111
|491
AI Summary
This article discusses the potential classes and their objects for a parking management system, along with a use case diagram. It also includes a class diagram, test table, and outline classes for the system.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
COVER PAGE
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
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 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.
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. Figure1:Use case diagram
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
2 Class diagram Figure2: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 IDRequirementDescriptionInputsExpected outputsPass/ Fail Comments A1.1FR12Find parking licensePlate of vehicle Enter 32- 3sfd Screen shot SS1 is displayed PLicense plate number is accepted Enter 23- 3sdf Screen shot SS2 is displayed PLicense plate number is accepted Enter EnterScreen shot SS3 isFLicense plate is
32-32assaddisplayedaccepted A1.2FR13Selecting menu option Select 1Screen shot SS4 is displayed F Select dScreen shot SS5 is displayed PA NumberFormatExce ption Exception was thrown 4 outline classes ï‚·Attendant publicclassAttendant{ privateintattendantID; privateStringname; privatebooleanavailability; publicAttendant(){} public voidsetAttendantID(intattID){ this.attendantID=attID; } public intgetAttendantID(){ returnthis.attendantID; } public voidsetName(StringattName){ this.name=attName; } publicStringgetName(){ returnthis.name; } publicStringtoString(){ returnthis.name+"-:"+attendantID; } public voidsetAvailability(booleanstatus){ this.availability=status; } public booleangetAvailability(){ returnthis.availability; } } ï‚·Driver ï‚·publicclassDriver{ privateStringlicensePlate; publicDriver(){} publicvoidsetlicensePlate(String plateNumber){ this.licensePlate=plateNumber; } publicStringgetLicensePlate(){
System.out.println("Zone ID: "+zoneData.get(i).getZoneID()+" "+zoneData.get(i).getType()); System.out.println("Type of vehicles accepted: "); for(intk=0;k<zoneData.get(i).getVehicles().size();k++){ Vehiclevehicle= (Vehicle)zoneData.get(i).getVehicles().get(k); System.out.append(vehicle.getType()+"\n"); } System.out.println("Spaces (True means the space is available and falsemeansitsnot)"); for(intj=0;j<zoneData.get(i).getSpaces().size();j++){ if(j%10==0){ System.out.println(); } System.out.print("\t "+zoneData.get(i).getSpaces().get(j).toString()); } System.out.println("\n"); } } publicvoidexitParking(){ System.out.println("Enter your receiptNO (Token)"); Scanners=newScanner(System.in); Stringtoken=s.next(); Receiptreceipt=findReceipt(token); if(receipt==null){ System.out.println("invaid receipt no or token..Refer to your receipt"); menu(); }else{ receipt.seExitTime(String.valueOf(System.currentTimeMillis())); longtimeDiff=Long.parseLong(receipt.getExitTime())- Long.parseLong(receipt.getArrivalTime()); longdiffInSeconds=timeDiff/1000; Doubleamount=Double.valueOf(0); if(diffInSeconds%3600==0){ amount=(diffInSeconds/3600)*getRate(receipt.getUserVehicle()); }else{ amount=(diffInSeconds/3600)*getRate(receipt.getUserVehicle()) +1*getRate(receipt.getUserVehicle()); } receipt.setAmount(amount); System.out.println("Charges for your parking ="+receipt.getAmount()); System.out.println("Enter your payment (should be the exact as specified)"); DoubleuserAmount; try{ userAmount=s.nextDouble(); if(userAmount<amount || userAmount>amount){ System.out.println("Incorrect amount"); System.out.println("Charges for your parking ="+receipt.getAmount()); System.out.println("Enter your payment (should be the exact asspecified)"); userAmount=s.nextDouble(); if(userAmount<amount || userAmount>amount){ System.out.println("Incorrect amount"); System.out.println("Charges for your parking ="+receipt.getAmount()); System.out.println("Enter your payment (should be the exactasspecified)");
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
userAmount=s.nextDouble(); }else{ System.out.println("Payment made"); } }else{ System.out.println("Payment made"); } }catch(Exception e){ System.out.println("Use numbers only"); } receipt.displayReceipt(); System.out.println("Exit parking within the next fifteen minutes"); System.out.println("Press 1 to raise barrier"); StringexitOption=s.next(); if(exitOption.equalsIgnoreCase("1")){ longcurrentTime=System.currentTimeMillis(); longdiff=(currentTime- Long.parseLong(receipt.getExitTime()))/1000; if(diff>15*60){ System.out.println("You have exceeded 15 minutes from the timeyoupaid..Seekassistance from an attendant"); }else{ System.out.println("Raising barrier..Bye"); } } menu(); } } publicDoublegetRate(Vehicle vehicle){ Doublerate=0.0; for(inti=0;i<vehicleData.size();i++){ if(vehicleData.get(i)==vehicle){ rate=vehicleData.get(i).getRate(); } } returnrate; } publicReceiptfindReceipt(String receiptNO){ Receiptreceipt=null; for(inti=0;i<receipts.size();i++){ if(receipts.get(i).getReceiptNO().equalsIgnoreCase(receiptNO)){ receipt=receipts.get(i); } } returnreceipt; } publicvoidstartup()throwsIOException { Loaderloader=newLoader(); //loadingthevehicle types ArrayList<ArrayList> vehicles=loader.populateData("./src/vehicles.txt"); for(inti=0;i<vehicles.size();i++){ Vehiclevehicle=newVehicle(); vehicle.setVehicleID(Integer.parseInt(vehicles.get(i).get(0).toString())); vehicle.setType(vehicles.get(i).get(1).toString()); vehicle.setRate(Double.parseDouble(vehicles.get(i).get(2).toString())); vehicleData.add(vehicle);
} //loadingthezonetypes ArrayList<ArrayList>zones=loader.populateData("./src/zones.txt"); for(inti=0;i<zones.size();i++){ Zonezone=newZone(); zone.setZoneID(Integer.parseInt(zones.get(i).get(0).toString())); zone.setType(zones.get(i).get(1).toString()); String[]cars=zones.get(i).get(2).toString().split(","); for(intk=0;k<cars.length;k++){ for(intl=0;l<vehicleData.size();l++){ if(Integer.toString(vehicleData.get(l).getVehicleID()).equals(cars[k])){ zone.setVehicles(vehicleData.get(l)); } } } for(intl=0;l<50;l++){ Spacespace=newSpace(); space.setSpaceID(l); space.setAvaialability(true); zone.setSpaces(space); } zoneData.add(zone); } // //loadingspace ArrayList<ArrayList> attendants=loader.populateData("./src/attendant.txt"); for(inti=0;i<attendants.size();i++){ Attendantattendant=newAttendant(); attendant.setAttendantID(Integer.parseInt(attendants.get(i).get(0).toString())); attendant.setName(attendants.get(i).get(1).toString()); attendant.setAvailability(true); attendantData.add(attendant); } } } 5 Evaluation The implementation of the proposed MCP system was both very informative and came with some challenges. The stages involved in making the system from the requirements gathering stage to the implementation and testing stage all came with a lot of lessons for me. I discovered that modelling a system using Unified Modelling Language (UML) for example by use of use case diagrams to show the
interaction of different users with the system and use of the class diagram to show the possible classes making up the process is the right way to follow when doing any project. This is because following these steps enabled me to get all the requirements of the proposed system before I started the actual implementation. The class diagram also helped me with the during the implementation stage because the structure of the system was already defined thus the coding part was simplified by following the structure. After the implementation was complete, the tests prepared before the implementation stage acted as checkpoints to verify and validate the system against the requirements. Use of inheritance in my program is the most sophisticated feature in the program. Inheritance helped me to reduce code repetition. Although understanding the actual working of the classes with inheritance was a bit technical for me, I got to understand it more after a few uses. Use of classes to emulate real life objects made the end system to achieve all functionalities required in the requirements.