This assignment delves into the creation of a rudimentary Java-based ticket generation system. The code demonstrates functions to generate both season and ordinary tickets, incorporating factors like day of the week and ticket charges. While incomplete, it serves as a foundation for understanding core programming concepts within a ticketing context.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
Running head:THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM The Java Programming of XYZ Car Parking System Name of the Student Name of the University
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
1THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM Table of Contents 1. Introduction:................................................................................................................................2 1.1 Background of the System:....................................................................................................2 2. Coding:........................................................................................................................................2 2.1 Customer.java:.......................................................................................................................2 2.2 Ticket.java:............................................................................................................................5 2.3 Payment.java:.......................................................................................................................10 3. Description of Developed Component:.....................................................................................11 4. Conclusion:................................................................................................................................16 Bibliography:.................................................................................................................................17
2THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM 1. Introduction: The java programming language has been selected for developing the prototype of the XYZ car parking system. The java Programming is the object oriented modelling that allows making a code dynamic and data handling better. Overloading of methods has been used within the programming. The programming does not cover all the aspects of the system as in order to that IoT is needed. The prototype version of the system provides proper understating ofthe system functionalities. 1.1 Background of the System: The system will be consisting of two types of customers such as ordinary and season. The ordinary customer purchases a ticket for only one day. The season customer buys a ticket for a certain months, three, six or twelve months. The season ticket holder also gets assigned a parking area which is reserved for him/her. The spaces are available for the weekdays. The allocated spaces becomes free to use for every customer in weekends. The tickets are generated based on the type of the customers. The season ticket holds the name of the user, address and it is valid for three, six or twelve months. Issue data and expiry date is recorded into the system. For the ordinary ticket, only the date and time of issuing is recorded. The payment can be through card or cash. The java programming has not been able to show the proper process of payment as IoT is needed to show that.
3THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM 2. Coding: 2.1 Customer.java: import java.util.Scanner; public class Customer { public static String rname; public static String nm; int cid, id, contact; String name, address, email; Customer(int cid, String name, String address, String email, int contact){ this.cid=cid; this.name=name; this.address=address; this.email=email; this.contact=contact; } void Display(){ System.out.println("Customer Details\n" + "name: " + name + " " + "address: " +address + " " + "email: " + email + " " + "contact: " + contact); }
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
4THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM void TicketGeneration(String nm){ this.nm=nm; Ticket.TicketBook(); System.out.println(nm+""+"Yourticketnumberis:"+ Ticket.TicketNumber + " \nDo you want to pay?" + " $" + Ticket.TicketCharge); Scanner s=new Scanner(System.in); char c= s.next().charAt(0); if (c == 'y' || c == 'Y') Payment.makePayment(); else System.out.println ("Payment Failed"); } public static void main (String a[]){ String n,ad,e; int co; int cid = 1; Customer cust = null; System.out.println("Do you want to enter new user: 1. Yes/ 2.No");
5THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM Scanner s=new Scanner(System.in); int choice; choice =s.nextInt(); if(choice == 1){ Scanner sc=new Scanner(System.in); System.out.println("Enter Customer Name"); n = sc.nextLine(); System.out.println("Address\n"); ad = sc.nextLine(); System.out.println("Email\n"); e = sc.nextLine(); System.out.println("Contact\n"); co = sc.nextInt(); cust = new Customer(cid, n, ad, e, co); cust.Display(); cust.TicketGeneration(n); } }
6THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM } 2.2 Ticket.java: import java.util.Scanner; import java.util.Date; import java.util.Calendar; public class Ticket { static Scanner s =new Scanner(System.in); static int TicketNumber; static int TicketCharge; static int Months; static boolean Status = true; Ticket(int TicketNumber, int TicketCharge, int Months){ this.TicketNumber = TicketNumber; this.TicketCharge = TicketCharge; this.Months = Months; } Ticket(int TicketNumber, int TicketCharge){ this.TicketNumber = TicketNumber;
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
7THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM this.TicketCharge = TicketCharge; Date Day = new Date(); } static void TicketBook(){ System.out.println("Choose your option\n 1. Season Ticket \n 2. Genral Ticket"); int option = 0; int z = 1; while(z == 1){ option = s.nextInt(); if(option == 1){ setData(); System.out.println("Yourseasonticketisconfirmedplease proceed to pay"); z = 0; } else if (option == 2) { setData2();
8THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM System.out.println("Your ordinary ticket is confirmed please proceed to pay"); z = 0; } else { System.out.println("The entered option is invalid"); System.out.println("Please choose again"); } } } private static void setData2() { Scanner sc=new Scanner(System.in); TicketNumber = 1+TicketNumber; Calendar c = Calendar.getInstance(); Date CurrentDate = new Date(); c.setTime(CurrentDate); int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); if ((dayOfWeek > 1) && (dayOfWeek < 7))
9THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM TicketCharge = 5; else TicketCharge = 10; Ticket t = new Ticket (TicketNumber, TicketCharge); } private static void setData() { Scanner sc=new Scanner(System.in); TicketNumber = 1+TicketNumber; System.out.println("Select Ticket Type 1. 12 months 2. 6 Months 3. 3 Months"); int c = sc.nextInt(); TicketCharge = TicketType(c); if (c==1) Months = 12; else if (c==2) Months = 6; else Months = 3; TicketCharge = TicketType(c);
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
10THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM Ticket t = new Ticket (TicketNumber, TicketCharge, Months); } private static int TicketType(int a) { if (a == 1) return 500; else if (a==2) return 375; else return 200; } public static void main(String a[]){ } } 2.3 Payment.java: public class Payment { static void makePayment(){ System.out.println("Meke Payment: " + "$" + Ticket.TicketCharge); System.out.println("Insert Money into the Machine");
11THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM System.out.println("Calculating Money"); System.out.println("Payment Done"); } public static void main (String a[]){ } } 3. Description of Developed Component: System.out.println("Do you want to enter new user: 1. Yes/ 2.No"); Scanner s=new Scanner(System.in); int choice; choice =s.nextInt(); if(choice == 1){ Scanner sc=new Scanner(System.in); System.out.println("Enter Customer Name"); n = sc.nextLine(); System.out.println("Address\n"); ad = sc.nextLine();
12THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM System.out.println("Email\n"); e = sc.nextLine(); System.out.println("Contact\n"); co = sc.nextInt(); cust = new Customer(cid, n, ad, e, co); This code shows that the system will be storing the customer details in the system. The details that will be stored within the system are name, address email and contact. These data will be stored against the cust object of Customer class. cust.Display(); This allows the system to call the following function void Display(){ System.out.println("Customer Details\n" + "name: " + name + " " + "address: " +address + " " + "email: " + email + " " + "contact: " + contact); } This will show the customer the details he/she has inputted into the system so that the provided data can be checked and modified if anything is wrong. ThroughcallingTicketGeneration(n)functionusingthecustobject (cust.TicketGeneration(n);), the system makes sure that the customer can generate ticket. This process is restricted to only generating ticket. If any has alreadyowns a ticket, then he/she can not use this function.
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
13THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM void TicketGeneration(String nm){ this.nm=nm; Ticket.TicketBook(); System.out.println(nm+""+"Yourticketnumberis:"+ Ticket.TicketNumber + " \nDo you want to pay?" + " $" + Ticket.TicketCharge); Scanner s=new Scanner(System.in); char c= s.next().charAt(0); if (c == 'y' || c == 'Y') Payment.makePayment(); else System.out.println ("Payment Failed"); } The nm variable represents the name of the customer. Ticket.TicketBook() is called by the system to generate the actual ticket. As the TicketBook() function is in the Ticket class, Ticket.TicketBook(); has been used. Ticket(int TicketNumber, int TicketCharge, int Months){ this.TicketNumber = TicketNumber; this.TicketCharge = TicketCharge; this.Months = Months;
14THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM } Ticket(int TicketNumber, int TicketCharge){ this.TicketNumber = TicketNumber; this.TicketCharge = TicketCharge; Date Day = new Date(); } The above code represents that the java programming for the XYZ car parking system uses the contractor overload feature of java to initialize the object. If the number of arguments are three then the season tickets are generated. Using two arguments is used for generating the ordinary ticket. These constrictors holds the variables TicketNumber and TicketCharge in common. This implies that every ticket in this prototype will have at least these two data. As the season ticket is booked for the months, the Ticket(int TicketNumber, int TicketCharge, int Months) represents the season ticket. private static void setData() { Scanner sc=new Scanner(System.in); TicketNumber = 1+TicketNumber; System.out.println("Select Ticket Type 1. 12 months 2. 6 Months 3. 3 Months"); int c = sc.nextInt(); TicketCharge = TicketType(c);
15THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM if (c==1) Months = 12; else if (c==2) Months = 6; else Months = 3; TicketCharge = TicketType(c); Ticket t = new Ticket (TicketNumber, TicketCharge, Months); } This function shows the process of generating the season ticket. The months are selected within this function. private static void setData2() { Scanner sc=new Scanner(System.in); TicketNumber = 1+TicketNumber; Calendar c = Calendar.getInstance(); Date CurrentDate = new Date(); c.setTime(CurrentDate); int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); if ((dayOfWeek > 1) && (dayOfWeek < 7))
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
16THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM TicketCharge = 5; else TicketCharge = 10; Ticket t = new Ticket (TicketNumber, TicketCharge); } The above function represents the process of creating the ordinary tickets. The dayOfWeek method is an inbuilt function of java which allows the system to check whether the ordinary ticket generation day is weekday or weekend. 4. Conclusion: From the above study it can be concluded that the ticket generation system calls different functions for different processes through few functions like Ticket.TicketBook(); is required to call if customer details are inputted properly. As the java program is a prototype not all the functions of the system has been provided into the programming. This programing only concentrates on creating a customer for the first time and generating ticket for him/her. The renewal of old ticket is not visualized into the programming. In order to make the code easy and understandable, inheritance is not used within the code. However, if a complete is to be done then the customer and ticket class can be utilizing the inheritance feature. The system is consisting of various IoTs. In order to provide a fully functional and complete code, integration of the IoT is inevitable. Lack of the IoT devices has made the payment class very simple. The logical functions can be implemented within the system. The payment verification is impossible
17THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM without customer providing money to the ticket counter or machine installed for taking cash or card.
18THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM Bibliography: Barnes, D. J., Kolling, M., & Gosling, J. (2017). Objects first with Java: A practical introduction using Bluej. Pearson. Carpenter, B., Gelman, A., Hoffman, M., Lee, D., Goodrich, B., Betancourt, M., ... & Riddell, A. (2016). Stan: A probabilistic programming language. Journal of Statistical Software, 20, 1-37. Edwards, S. A. (2014). The Programming Language Landscape. Flanagan, C., Leino, K. R. M., Lillibridge, M., Nelson, G., Saxe, J. B., & Stata, R. (2013). PLDI 2002: Extended static checking for Java. ACM Sigplan Notices, 48(4S), 22-33. Liang, Y. D. (2013). Introduction to Java programming: brief version. Pearson. Slaughter, E., Lee, W., Treichler, S., Bauer, M., & Aiken, A. (2015, November). Regent: a high- productivity programming language for HPC with logical regions. In High Performance Computing, Networking, Storage and Analysis, 2015 SC-International Conference for (pp. 1-12). IEEE. Urma, R. G., & Mycroft, A. (2015). Source-code queries with graph databases—with application to programming language usage and evolution. Science of Computer Programming, 97, 127-134.