Top Banner

of 12

The Report of Laughs Parking Management System Low Cap

Apr 07, 2018

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/6/2019 The Report of Laughs Parking Management System Low Cap

    1/12

    University of Colombo School of Computing

    2011

    The Report of Laughs Parking Management

    SystemData Structures and Algorithms

    By Yasassri Chaturange Ratanayake

  • 8/6/2019 The Report of Laughs Parking Management System Low Cap

    2/12

    U n i v e r s i t y o f C o l o m b o S c h o o l o f C o m p u t i n g Page 1

    Report of Laughs Management System 2011

    Contents

    The Report of Laughs Parking Management System ................................................................................... 0

    Introduction .............................................................................................................................................. 2

    Requirements: ........................................................................................................................................... 2

    The System & Development: .................................................................................................................... 3

    Outputs Outcomes and Test data ............................................................................................................. 3

    Source Code: ......................................................................................................................................... 5

    Pseudo Code ........................................................................................................................................... 11

    http://c/Users/Yasassri/Desktop/AlgoAssignment/The%20report%20of%20Laughs%20Parking%20Management%20System.docx%23_Toc291358750http://c/Users/Yasassri/Desktop/AlgoAssignment/The%20report%20of%20Laughs%20Parking%20Management%20System.docx%23_Toc291358750http://c/Users/Yasassri/Desktop/AlgoAssignment/The%20report%20of%20Laughs%20Parking%20Management%20System.docx%23_Toc291358750
  • 8/6/2019 The Report of Laughs Parking Management System Low Cap

    3/12

    U n i v e r s i t y o f C o l o m b o S c h o o l o f C o m p u t i n g Page 2

    Report of Laughs Management System 2011

    Introduction

    The laughs parking garage consists of 10 allocated spaces for parking vehicles. The garage

    contains single lane drive thru and the vehicles are taken out from the northernmost entrance and

    the vehicles are driven in thru the southernmost entrance. To accommodate people who want to

    park their vehicles in the garage the management is maintaining a waiting queue outside the

    garage itself. Any vehicle can depart any time according to the owners will, and vehicle

    movement counter has been initialized to give more information to the user about the movements

    of the vehicles within the garage. This system is being created to help the management of Laughs

    Parking Garage to provide an efficient service to the customer.

    Requirements:

    Specific requirements were provided by the stake holder to facilitate and to guide the software

    development procedure. But in some cases ambiguity occurred and different assumptions were

    made according to the developers understanding.

    The requirements provided were as follows:

    This program should read a group of input lines. Each line contains an a arrival or a d

    departure and a license plate number. Cars are assumed to arrive and depart in the order specified

    by the input. The program should print a message each time that a car arrives or departs. When a

    car arrives, the massage should specify whether or not there is room for the car in garage. If

    there is no room for a car, the car waits until there is room or until a departure line is read for the

    car. When room becomes available, another massage should be printed. When a car departs, the

    massage should include the number of times the car was moved within the garage (including the

    departure itself but not the arrival), this number is 0 if the car departs from the waiting line.

  • 8/6/2019 The Report of Laughs Parking Management System Low Cap

    4/12

    U n i v e r s i t y o f C o l o m b o S c h o o l o f C o m p u t i n g Page 3

    Report of Laughs Management System 2011

    The System & Development:

    Imported Linked Lists were used to make the code simple and very readable rather than using

    manually built Linked Lists. This allowed the developer to save time and add many more features to the

    system. The software facilitates the basic needs of a parking system and further some enhanced feature

    as well. The main actions in the software can be listed as follows.

    1. Parking Vehicles.2. Retrieving vehicles.3. Viewing parking information.4. Adding vehicles to the waiting queue.5. Retrieving vehicles from the waiting list.6. Viewing information about the waiting queue.7. Counting movements of individual vehicles.8. Writing data into a data file.9. Initializing the system using the data file10.Clearing all the Lists.11.Checking for Duplicates.

    The Enhanced features (nonfictional) of the system can be listed as follows.

    12.Allowing user interaction to the maximum level.13.Large variety of selections.14.Command line data entry.15. Inserting data through data files.

    Outputs Outcomes and Test data

    When we consider this garage system the expected out puts of the system are,

    1. Informing User about success or the failure of the parking and retrieving procedures.2. Giving error messages when an error occurs.

    Basic Actions (Functional)

    Reliability Based Actions (Nonfunctional)

    Security Based Actions (Nonfunctional)

  • 8/6/2019 The Report of Laughs Parking Management System Low Cap

    5/12

    U n i v e r s i t y o f C o l o m b o S c h o o l o f C o m p u t i n g Page 4

    Report of Laughs Management System 2011

    Eg : Wrong Preference Errors, Exceptions etc.

    3. Viewing selection menus.4. Providing information about the parking area and about the waiting list.5. Viewing vehicle counters.

    The outcome of this system is efficient management of the parking garage. This system can be

    developed further if the user wants to widen the requirements. For eg : Payment System

    according to the parking duration etc. the System can be further developed in security aspect if

    the system can directly communicate with the RMV(Registrar of Motor Vehicles ). The system

    can cross check all the numbers for fraudulent numbers. May be the user can broaden the

    security aspect by connecting with the Police Department database and checking for wanted

    numbers who has committed illegal actions.

    The System was developed using java and its tools, and basically using Eclipse. The actions

    were implemented using simple logics and algorithms.

    Different data was used to Test this system. First to test the parking process different types of

    numbers were used; firstly a single number was used as the car number in order to save time of

    inputting data. For eg : a1, a2, a3, A5, A6, d1, d5, d9, D3

    All the possible errors that can occur were tested in the testing procedure.

    For Eg: The wrong actions error, Cannot find vehicle error, Wrong user Input error, Trying to

    remove non existing Vehicles error, Wrong number format error, Duplicate Existing numbers

    error, Null Pointer errors, Input miss match errors, No data file errors etc.

    This test data was used to fix bugs and mal functions of the software, and to develop the existing

    features even further.

    After the system was fully developed the System was tested with Full plate numbers, all the

    possible action, errors and bugs were tested in this final testing.

    Eg : a12-5733 d34-7815 adf-5681 aDF-8794 dGT-3819 etc.

  • 8/6/2019 The Report of Laughs Parking Management System Low Cap

    6/12

    U n i v e r s i t y o f C o l o m b o S c h o o l o f C o m p u t i n g Page 5

    Report of Laughs Management System 2011

    Source Code:

    import java.io.*;

    import java.util.*;

    /*

    * Author : Yasassri Chaturange Ratnayake

    * File : Parking.java* Name of the System : Laughs Parking Management System

    * Description : This Software is developed to handle operations in a parking garage

    */

    publicclass Parking {

    // Initializing the Linked list

    static LinkedList parkedList = new LinkedList();

    static LinkedList waitingList = new LinkedList();

    // The main methodpublicstaticvoid main(String[] args) {

    boolean bvalue = true;

    while (bvalue == true) {

    try {

    // Main Menu

    Scanner selection = new Scanner(System.in);

    System.out.println("\n\t\t|||||||||||||||||||||||||||||||||||||||||||||||||" );

    System.out.println("\t\t***Welcome To Laughs Parking Management System***");

    System.out.println("\t\t|||||||||||||||||||||||||||||||||||||||||||||||||\n" );System.out.println("> Press 1 to park or to Retrieve a Vehicle");

    System.out.println("> Press 2 to get Information about Parking spaces");

    System.out.println("> Press 3 to View the waiting List");

    System.out.println("> Press 4 to view the Vehicle movement counter");

    System.out.println("> Press 5 to Write data to a database");

    System.out.println("> Press 6 to initialize the system and to restore data from

    the database");

    System.out.println("> Press 7 to delete all data from the Lists");

    System.out.println("> Press 8 to Exit the System\n");

    System.out.print(">>Select your Preference : ");

    int select = selection.nextInt();

    if (select == 1) {

    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

    System.out.println("\n>Enter The Car Number and the Action you want to

    carryout.");

    System.out.println(" Tip : Enter the letter 'a' infront of the car Number topark or Enter letter 'd' if you want to retrieve a vehicle(Eg aWE-1635 d12-8643)");

    System.out.print("\n>>Enter: ");

    String input = stdin.readLine();

    System.out.println();

    //Splitting the string by spaces.

    String array[] = input.split(" ");

    for (int i = 0; i < array.length; i++) {

    String carnumber = array[i];

    // Breaking the String into a sub String.

    String firstLetter = carnumber.substring(0, 1);

    String carNumber;if (carnumber.length() == 8) {

    if (firstLetter.equalsIgnoreCase("a")) {

    carNumber = carnumber.substring(1, 8);

    //Parsing the car number to the parking method.

    parking(carNumber);

    } elseif (firstLetter.equalsIgnoreCase("d")) {

    carNumber = carnumber.substring(1, 8);

    carDeparture(carNumber);

    } else {

    System.out.println(i + "*WARNING!!!!Action you Preffered is

    Incorrect!!!!");

    }

  • 8/6/2019 The Report of Laughs Parking Management System Low Cap

    7/12

    U n i v e r s i t y o f C o l o m b o S c h o o l o f C o m p u t i n g Page 6

    Report of Laughs Management System 2011

    } else {

    System.out.println("* Vehicle Number " + i + " you entered is not in

    correct format, Please enter a Valid Numbers");

    }

    }

    } elseif (select == 2) {

    System.out.println("\n>There are " + parkedList.size() + " Vehicle(s) in

    the parking Area");

    System.out.println();

    if(parkedList.size()>0){

    System.out.println(">The Vehicles are parked in the Guarage in the

    following Order. ");

    getParkedList();

    }

    } elseif (select == 3) {

    if(waitingList.size()==0){

    System.out.println("\n*There are No vehicles in the Waiting

    queue!!!");

    }if(waitingList.size()>0){

    System.out.println(">There are " + waitingList.size() + " Vehicles

    in the waiting Queue.");

    System.out.println(">The Vehicles are waiting in the following

    Order.");

    getWaitingList();}

    }

    elseif(select == 4){

    movementCounter();

    }elseif(select == 5){

    writeToTextfile();

    }

    elseif(select == 6){

    dataInitializer();

    }elseif(select == 7){

    parkedList.clear();

    waitingList.clear();

    System.out.println("#Parking List and waiting Queue Cleared

    Successfully!!!");

    }elseif (select == 8) {

    //Exiting the System.

    System.out.println("####System Terminated Successfully!###");

    System.exit(0);

    }

    else {

    System.out.println("*WARNING : Wrong Preference Please Select again");

    }

    } catch (InputMismatchException e) {

    //Not Exiting after the exception, going back to the main menu.

    System.out.println("*WARNING!!! : The Character(s) you Entered is/are

    Incorrect!!!!");

    main(new String[]{});

    }

    catch (Exception e) {System.out.println("!!!!IO Exception is Handled!!!!");

    //Not Exiting after the exception, going back to the main menu.main(new String[]{});

    }

    }

    }

    // Parking vehicles method

    publicstaticvoid parking(String carNumber) {

    try {

    if (duplicateChecker(carNumber)) {

    Scanner input4 = new Scanner(System.in);

  • 8/6/2019 The Report of Laughs Parking Management System Low Cap

    8/12

    U n i v e r s i t y o f C o l o m b o S c h o o l o f C o m p u t i n g Page 7

    Report of Laughs Management System 2011

    System.out.println("\n>Press 1 If you want to Skip the Procedure of

    the vehicle "+ carNumber);

    System.out.println(">Press any Other key if you want to add the

    vehicle anyway.");

    System.out.println("\n>Enter: ");

    int inp = input4.nextInt();

    if (inp == 1) {

    System.out.println("\n*The Parking of the Vehicle '"

    +carNumber+"' Abandoned Succesfully!!");return;

    } else {

    }

    }} catch (Exception e) {

    }

    // Creating a new car Object

    carinfo carObject = new carinfo();

    //Setting the name, Parsing the car number to the object,

    carObject.setName(carNumber);if (parkedList.size() < 10) {

    // Viewing a Message when there is a vacancy in the garage

    if(parkedList.size()==9 && waitingList.size()>0){

    parkedList.add(waitingList.get(0));System.out.println("#The Vehicle Bearing the Number '"+ carNumber+"' added

    to the parking area succesfully!!");

    return;

    }

    // Adding the car object into the array list.

    parkedList.add(carObject);

    System.out.println("+The Vehicle Bearing the Number "+ carNumber+" added to the

    parking area succesfully!!");

    } else {

    System.out.println("\n!!!!!!!PARKING AREA IS FULL!!!!!!!");

    System.out.println();

    System.out.println("\n>Please Enter 1 if you want to add the vehicle with the

    Number '"+carNumber+ "' into the waiting Queue:");

    System.out.println(">Please Enter 2 if you want to Skip the vehicle bearing the

    Number '"+carNumber+"'");

    System.out.println(">Enter any other to go to the main Menu");

    try{Scanner input2 = new Scanner(System.in);int input3 = input2.nextInt();

    if(input3==1){

    //Adding the car Object to the waiting list.

    waitingList.add(carObject);

    System.out.println("\n++Operation Seccesful!!!");

    System.out.println();

    }if(input3==2){

    System.out.println("\n#The Vehicle is skipped and removed Sucesfully!");

    System.out.println();

    }}catch(Exception e){

    main(new String[]{});

    }

    }

    }

    //Removing Vehicles from the park or waiting list.publicstaticvoid carDeparture(String carNumber) {

    for (int i = 0; i < parkedList.size(); i++) {

    if (parkedList.get(i).getName().equalsIgnoreCase(carNumber)) {

    for (int j = 0; j < parkedList.size(); j++) {

    // this is to differentiate the counter by position.

    if(j

  • 8/6/2019 The Report of Laughs Parking Management System Low Cap

    9/12

    U n i v e r s i t y o f C o l o m b o S c h o o l o f C o m p u t i n g Page 8

    Report of Laughs Management System 2011

    }

    else{

    parkedList.get(j).increaseMoveCount();

    }

    }

    System.out.println("");

    System.out.println("\n+The Vehicle Bearing the Number '"

    +parkedList.get(i).getName() + "' was removed from the Parking area succesfully!!");

    System.out.println("#This Vehicle was moved " +

    parkedList.get(i).getMoveCount()+" time(s) within the Garage.");

    parkedList.remove(i);

    System.out.println();

    if (parkedList.size() < 10 && waitingList.size()>0) {

    System.out.println("!!!!!!!There is a vacancy in the parking

    area!!!!!!!");

    System.out.println("\n>Please Enter 1 if you want to add a vehicle from

    the waiting List to the vacant area.");

    System.out.println(">Press any other key to go to the main menu.");

    System.out.println();

    System.out.print(">Enter : ");

    Scanner input = new Scanner(System.in);

    int input0 = input.nextInt();

    if(input0==1){parkedList.add(waitingList.get(0));

    waitingList.remove();

    }else{

    return;

    }

    }

    return;

    }

    }

    try{

    Scanner input1 = new Scanner(System.in);

    System.out.println("*There is No Vehicle Bearing the Number '" +carNumber+ "' in the

    Parking Area!!!");System.out.println("\n>Please Enter Number 1 if you want to continue your search in the

    Waiting Queue.");

    System.out.println(">Pree any other to go to the Main Menu.");

    System.out.println();

    System.out.print(">Enter : ");

    int in = input1.nextInt();

    if(in==1){

    removeFromWaitingList(carNumber);

    }

    else{

    main(new String[]{});

    }

    } catch(InputMismatchException e){

    main(new String[]{});}

    }

    // Removing Objects from the waiting List.

    publicstaticvoid removeFromWaitingList(String carName) {

    for (int i = 0; i < waitingList.size(); i++) {

    if (waitingList.get(i).getName().equalsIgnoreCase(carName)) {

    System.out.println("#The Vehicle bearing the number

    '"+waitingList.get(i).getName() + "' was moved 0 times within the garage.");

    waitingList.remove(i);

  • 8/6/2019 The Report of Laughs Parking Management System Low Cap

    10/12

    U n i v e r s i t y o f C o l o m b o S c h o o l o f C o m p u t i n g Page 9

    Report of Laughs Management System 2011

    break;

    }

    }

    }

    // parking list Printing method.

    publicstaticvoid getParkedList() {

    for (int i = 0; i < parkedList.size(); i++) {

    System.out.print(parkedList.get(i).getName() + ",");

    }

    System.out.println("");

    }

    // Waiting List Printing methodpublicstaticvoid getWaitingList() {

    for (int i = 0; i < waitingList.size(); i++) {

    System.out.print(waitingList.get(i).getName() + ",");

    }

    System.out.println("");

    }

    // Movement Counter method

    publicstaticvoid movementCounter(){

    try {

    Scanner input4 = new Scanner(System.in);

    System.out.println(">Enter Number 1 to view the complete list of

    counters"); System.out.println(">Enter Number 2 to view a Specific Vehicle Counter ");

    System.out.println();

    System.out.print(">Enter :");

    int in = input4.nextInt();

    if (in == 1) {

    System.out.println("\nCar Number\tNumber Of Movements");

    for (int i = 0; i < parkedList.size(); i++) {

    System.out.println(" " + parkedList.get(i).getName()+ "

    \t\t\t" + parkedList.get(i).getMoveCount());

    }

    }

    elseif(in==2){

    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    System.out.print("\n>Enter The Vehicle number: ");

    String input = reader.readLine();for (int i = 0; i < parkedList.size(); i++) {

    if(parkedList.get(i).getName().equalsIgnoreCase(input)){

    System.out.println("Car Number\tNumber Of Movements");

    System.out.println(" " + parkedList.get(i).getName()+ "

    \t\t\t" + parkedList.get(i).getMoveCount());

    return;

    }

    }

    System.out.println("\n*WARNING:There is no Such vehicle with the Number you

    Entered!!!");

    }

    }catch (Exception e) {

    System.out.println("\n*Wrong Input!!!!!!");

    movementCounter();

    }}

    //Checking weather there are Duplicates.publicstaticboolean duplicateChecker(String carNumber){

    boolean value = false;

    if (parkedList.size()>0) {

    for (int i = 0; i < parkedList.size(); i++) {

    if(parkedList.get(i).getName().equalsIgnoreCase(carNumber)){

    System.out.println("\n!!WARNING: A vehicle with the Number '"

    +carNumber+"' already exsits in the Parking Area.");

    value = true;

    break;

  • 8/6/2019 The Report of Laughs Parking Management System Low Cap

    11/12

    U n i v e r s i t y o f C o l o m b o S c h o o l o f C o m p u t i n g Page 10

    Report of Laughs Management System 2011

    }

    }

    }if (waitingList.size()>0) {

    for (int j = 0; j < waitingList.size(); j++) {

    if(waitingList.get(j).getName().equalsIgnoreCase(carNumber)){

    System.out.println("\n!!WARNING: A vehicle with the Number '"

    +carNumber+"' already exsits in the Waiting Area!!");value=true;

    break;

    }

    }

    }

    return value;

    }

    publicstaticvoid writeToTextfile(){

    try {

    //Checking if there are vehicles in the park.if(parkedList.size()>0){

    BufferedWriter writer = new BufferedWriter(new

    FileWriter("parkedList.txt"));

    for (int i = 0; i < parkedList.size(); i++) {writer.write(parkedList.get(i).getName()+"

    "+parkedList.get(i).getMoveCount());

    writer.newLine();

    }

    System.out.println("\n#Data Written to the File Succesfully!!");

    writer.flush();}

    else{

    System.out.println("\n#There are No vehicles in the parking Area!!");

    }}catch (Exception e) {

    System.out.println("*Error!!!!");

    }

    }

    // Data Initializing Method

    publicstaticvoid dataInitializer(){

    try {

    BufferedReader reader = new BufferedReader(newFileReader("parkedList.txt"));

    String line;

    int lineCounter=0;

    while((line=reader.readLine())!=null){

    String array[] = line.split(" ");

    parking(array[0]);

    parkedList.get(lineCounter).setCounter(Integer. parseInt(array[1]));

    }} catch (Exception e) {

    System.out.println("WARNING : Data file NOT found!!!!");

    }

    }

    }

    // Car Object classclass carinfo {

    private String name;

    privateintmoveCount= 0;

    public String getName() {

    returnname;

    }

    publicvoid setCounter(int count){

    moveCount= count;

    }

  • 8/6/2019 The Report of Laughs Parking Management System Low Cap

    12/12

    U n i v e r s i t y o f C o l o m b o S c h o o l o f C o m p u t i n g Page 11

    Report of Laughs Management System 2011

    publicvoid setName(String name) {

    this.name = name;

    }

    publicint getMoveCount() {

    returnmoveCount;

    }

    publicvoid increaseMoveCount() {

    moveCount++;

    }

    }

    Pseudo Code