Repository navigation
Expand file tree
/
Copy pathAmusementParkTester.java
More file actions
162 lines (147 loc) · 6.69 KB
/
Copy pathAmusementParkTester.java
File metadata and controls
162 lines (147 loc) · 6.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package wk8proj;
/**
*
* @author Mohnani
*/
import java.util.ArrayList;
import java.util.Iterator;
import java.time.LocalDate;
import java.text.SimpleDateFormat;
import java.util.Scanner;
public class AmusementParkTester {
public static void main(String args[])
{
AmusementPark ap=new AmusementPark("Walden Amusement Park");
while(true)
{
Scanner myscan = new Scanner(System.in);
System.out.println("Enter a Choice:");
System.out.println("0: getTicketDates");
System.out.println("1: getTickets for a Date");
System.out.println("2: getTicket for an Id");
System.out.println("3: get all Merchandise");
System.out.println("4: get Merchandise for an id");
System.out.println("5: get Merchandise for a category");
System.out.println("6: add a new Ticket to the inventory of the AmusementPark");
System.out.println("7: add a new Merchandise to the inventory of the AmusementPark");
System.out.println("8: buy Merchandise");
System.out.println("9: buy Ticket");
System.out.println("X: Exit");
System.out.println("Your Input please ---> ");
String s=myscan.nextLine();
if (s.equals("X") || s.equals("x"))
{
System.out.println("Received X");
System.out.println("Thanks! Exiting");
System.exit(0);
}
else if(s.equals("0"))
{
ArrayList<LocalDate> dl=new ArrayList<LocalDate>();
System.out.println("Calling getTicketDates");
dl=ap.getTicketDates();
for(int i=0;i<dl.size();i++)
{
System.out.println(dl.get(i));
}
}
else if(s.equals("1"))
{
System.out.println("You chose (1) getTickets for a Date");
System.out.println("Enter Date as YYYY-MM-DD ->");
String ss=myscan.nextLine();
int i = ap.getTickets(LocalDate.parse(ss));
System.out.println("Available Tickets for Date "+ss+ " are : "+String.valueOf(i));
}
else if(s.equals("2"))
{
// Get Ticket for an Id
System.out.println("You chose (2) get Ticket for an Id");
System.out.println("Enter Id of Ticket -> ");
String ss=myscan.nextLine();
Ticket i = ap.getTicket(Integer.parseInt(ss));
System.out.println("Ticket for id "+ss+ " is : "+i.toString());
}
else if(s.equals("3"))
{
ArrayList<Merchandise> mlnew=new ArrayList<Merchandise>();
mlnew=ap.getMerchandise();
for (int i=0;i<mlnew.size();i++)
{
System.out.println(mlnew.get(i).toString());
}
}
else if(s.equals("4"))
{
// Get Merchandise for an Id
System.out.println("You chose (4) get merchandise for an Id");
System.out.println("Enter Id of Merchandise -> ");
String ss=myscan.nextLine();
Merchandise i = ap.getMerchandise(Integer.parseInt(ss));
System.out.println("Merchandise for id "+ss+ " is : "+i.toString());
}
else if(s.equals("5"))
{
//get Merchandise for a category
System.out.println("You chose (5) get merchandises for a category");
System.out.println("Enter category of Merchandise -> ");
String ss=myscan.nextLine();
ArrayList<Merchandise> mlnew=new ArrayList<Merchandise>();
mlnew=ap.getMerchandise(ss);
for (int i=0;i<mlnew.size();i++)
{
System.out.println(mlnew.get(i).toString());
}
}
else if(s.equals("6"))
{
System.out.println("Add a new Ticket to the inventory of the AmusementPark");
System.out.println("Enter category (adult, child, senior)-> ");
String category=myscan.nextLine();
System.out.println("Enter Holder's Name-> ");
String holder=myscan.nextLine();
System.out.println("Enter Date in format YYYY-MM-DD -> ");
LocalDate date=LocalDate.parse(myscan.nextLine());
System.out.println("Enter Price -> ");
double price=myscan.nextDouble();
System.out.println("Enter Purchase Status (true=purchased / false=reserved -> ");
boolean purchaseStatus=myscan.nextBoolean();
Ticket t=new Ticket(ap.getMaxTicketId()+1,category,holder,date,price,purchaseStatus);
ap.tickets.add(t);
}
else if(s.equals("7"))
{
System.out.println("Add a new Merchandise to the inventory of the AmusementPark");
System.out.println("Enter category (T-Shirt, Sweatshirt, Stuffed Animal)-> ");
String category=myscan.nextLine();
System.out.println("Enter Description-> ");
String description=myscan.nextLine();
System.out.println("Enter Price -> ");
double price=myscan.nextDouble();
System.out.println("Enter In-Stock Status (true=In Stock / false=On Order-> ");
boolean inStock=myscan.nextBoolean();
Merchandise m=new Merchandise(""+ap.getMaxMerchandiseId()+1,category,description,price,inStock);
ap.merchandises.add(m);
}
else if(s.equals("8"))
{
System.out.println("Enter Merchandise ID to Buy -> ");
String str="";
int maxid;
long i=myscan.nextLong();
ap.buyMerchandise(String.valueOf(i));
}
else if(s.equals("9"))
{
System.out.println("Enter Ticket ID to Buy -> ");
long i=myscan.nextLong();
ap.buyTicket(String.valueOf(i));
}
}
}
}