The Java Programming of XYZ Car Parking System Prototype Project

Verified

Added on  2020/02/24

|19
|2557
|43
Project
AI Summary
This Java programming project details the development of a prototype for an XYZ car parking system. The system utilizes object-oriented programming principles, with a focus on customer management and ticket generation. The project encompasses three main classes: Customer, Ticket, and Payment. The Customer class handles customer details, including name, address, email, and contact information, and facilitates ticket generation based on customer type (ordinary or season). The Ticket class manages ticket types (season and ordinary), calculates ticket charges, and assigns ticket numbers. The Payment class simulates the payment process. The code demonstrates the use of methods, constructors, and conditional logic to simulate the core functionalities of the parking system. While the prototype does not include all aspects of a complete system, such as IoT integration for payment processing, it offers a foundational understanding of the key components and their interactions within a car parking system.
Document Page
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
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
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
Document Page
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 of the
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.
Document Page
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);
}
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
4THE JAVA PROGRAMMING OF XYZ CAR PARKING SYSTEM
void TicketGeneration(String nm){
this.nm=nm;
Ticket.TicketBook();
System.out.println(nm + " " + "Your ticket number is: " +
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");
Document Page
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);
}
}
Document Page
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;
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
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("Your season ticket is confirmed please
proceed to pay");
z = 0;
}
else if (option == 2)
{
setData2();
Document Page
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))
Document Page
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);
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
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");
Document Page
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();
chevron_up_icon
1 out of 19
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]