0 оценок0% нашли этот документ полезным (0 голосов)
16 просмотров18 страниц
This document describes a parking cost management system project that calculates fees based on parking duration. It includes class diagrams, code snippets, and discussions of problems encountered and solutions. The key problems addressed were searching for specific data in files with multiple entries, resetting slot status across runs, removing parked car data when exiting, and handling duplicate number plates. Solutions involved filtering files, constructor initialization, and exception handling. Overall, the project helped strengthen OOP and problem-solving skills.
This document describes a parking cost management system project that calculates fees based on parking duration. It includes class diagrams, code snippets, and discussions of problems encountered and solutions. The key problems addressed were searching for specific data in files with multiple entries, resetting slot status across runs, removing parked car data when exiting, and handling duplicate number plates. Solutions involved filtering files, constructor initialization, and exception handling. Overall, the project helped strengthen OOP and problem-solving skills.
This document describes a parking cost management system project that calculates fees based on parking duration. It includes class diagrams, code snippets, and discussions of problems encountered and solutions. The key problems addressed were searching for specific data in files with multiple entries, resetting slot status across runs, removing parked car data when exiting, and handling duplicate number plates. Solutions involved filtering files, constructor initialization, and exception handling. Overall, the project helped strengthen OOP and problem-solving skills.
Details Of working Code Snippets Problem faced Solutions For The Problems Learning From the Project Our aim for this project was to design and implement a program that handles the parking cost for any time period. The Price calculated for each car during parking depends on the time it was parked and the time it exits a specific parking slot. The scope behind the project is to provide a systematic way of managing the parking system for any firm or company. This ensures fair charges for each user of the parking slots. When there is a new entry, the function DataIn() from class Parker is called after asking the user to input the name, number plate and age of the parker and then stores it in a file with a variable string name. In the function Set_Entry(), the slot coordinates are automatically assigned for each parker and stored in that same file. After that it stores the time in terms of hours, minutes, seconds along with the slot coordinates in another file named as “TimeIn.txt”. When the function DataOut() is called from the class Parker, it will ask the user about the number plate of the car as the first file it has to open is the one which is named as the number plate of the parker’s car. Then it reads the Slot Coordinates which was stored in that file which is then used to search the specific slot in the “TimeIn.txt” file when the function Get_Entry() is called from the class File. After that it will retrieve the information regarding the time and hence calculate the price. The following picture shows the code for the File() constructor which is used to initialize the status of the slots after the program run. This is used because as we leaves the program and rerun it, the slots would reset even if the data exists in the file, so this creates confusion when retrieving the data from the file regarding the slots coordinate. It will read the file and count the number of groups of data. Note that one group of data is for one person. The next piece of code shows the function from class Parker which is named as DataIn() is shown. The file is created with a variable name of string type. That variable is actually used for the number plate of the car. We can see that the function Set_Entry(h, m, s) is called before writing the coordinate i, j in the file. The value of i, j is set automatically after the function runs. The piece of code in the Set_Entry(int x, int y, int z) which automatically set the value of coordinates i, j is shown in the next slide. Also it checks the status of that coordinate that whether it is occupied or not. If it is occupied at i, j, then the spots[i][j] = ‘1’. The initial value of i, j is 1 and 0 respectively which is set in the File() constructor and at the start of the Set_Entry() function. The next piece of the code shows the function bool DataOut() from the class Parker. Now the next piece code shows the function Get_Entry() from class File. The first two line of data in a single group in ”TimeIn.txt” file corresponds to the slot coordinates, so we used the ‘if’ statement to check whether any of the groups of data that is currently stored matches the slot coordinate as obtained in DataOut() function. After that there is a second time run of the file stream that write the rest of the groups of data excluding the desired one into another file having the same name and overwrite the older one. In this way we are able to remove any specific group of data in a file. Now the following code shows the class Time. The first problem was about how to search for a particular group of data from a file that already contains more than one group. The second problem was that if the program exits and if there is already some entries, the next time the program runs, the slots would get reset even though the file containing the data already exists. The third problem was that if there is an exit, the information regarding the slot coordinates and the time of entry would still exist and can be searched again even if the program exits. The fourth problem was that if there is another entry with the same number plate, the program would then overwrite the previous file which was name as the number plate of the car, removing the data of the previous entry. For the first problem, we used the ‘if’ statement to search for a specific group of data as described earlier. After finding a match it will simply then output it to the screen. For the second problem, we used constructors. There are two constructors i.e. Parking() and File(). The first one simply resets the slots status, the second one initialize a file stream object that opens the “TimeIn.txt” file and search for the number of groups of data and increment the value of usedSpots. For the third problem, we used the a method to filter out the remaining data other than the required one and saving those data in the same file by overwriting the “TimeIn.txt” file. Now for the fourth problem, we simply used exceptional handling to cope with ambiguity and unwanted problems regarding existence of a file or problems that occur when a user gives a repeated input. Doing this project helped us to understand the concepts of OOP and the importance of it in designing and implementing any complex program. We learned about new techniques to cope and solve a problem during the project like filtering a specific data in a file. Our Filing techniques were greatly enhanced during this project as there were different modes of filing which were involved. Our ability to solve problems like unwanted behavior of the program due to undesired inputs, were enhanced and polished.
Python Advanced Programming: The Guide to Learn Python Programming. Reference with Exercises and Samples About Dynamical Programming, Multithreading, Multiprocessing, Debugging, Testing and More