SlideShare a Scribd company logo
1 of 21
© 2014 Laureate Education, Inc. Page 1 of 4
Retail Transaction Programming Project
Project Requirements:
1. Develop a program to emulate a purchase transaction at a
retail store. This
program will have two classes, a LineItem class and a
Transaction class. The
LineItem class will represent an individual line item of
merchandise that a
customer is purchasing. The Transaction class will combine
several LineItem
objects and calculate an overall total price for the line item
within the transaction.
There will also be two test classes, one for the LineItem class
and one for the
Transaction class.
2. Design and build a LineItem class. This class will have three
instance variables.
There will be an itemName variable that will hold the
identification of the line item
(such as, "Colgate Toothpaste"); a quantity variable that will
hold the quantity of
the item being purchased; and a price variable that will hold the
retail price of the
item. The LineItem class should have a constructor, accessors
for the instance
variables, a method to compute the total price for the line item,
a method to
update the quantity, and a method to convert the state of the
object to a string.
Using Unified Modeling Language (UML), the class diagram
looks like this:
LineItem
- itemName : String
- quantity : int
- price : double
+ LineItem( String, int, double )
+ getName( ) : String
+ getQuantity( ) : int
+ getPrice( ) : double
+ getTotalPrice( ) : double
+ setQuantity( int )
+ setPrice( double )
+ toString( ) : String
a. The constructor will assign the first parameter to the instance
variable
itemName, the second parameter to the instance variable
quantity, and
the third parameter to the instance variable price.
b. The class will have three accessor methods—getName( ),
getQuantity( ),
and getPrice( )—that will return the value of each respective
instance
variable.
© 2014 Laureate Education, Inc. Page 2 of 4
c. The class will have two mutator methods, setQuantity( int )
and setPrice(
double ), that will update the quantity and price, respectively,
of the item
associated with the line of the transaction.
d. The method getTotalPrice( ) handles the conversion of the
quantity and
price into a total price for the line item.
e. The method toString( ) allows access to the state of the object
in a
printable or readable form. It converts the variables to a single
string that
is neatly formatted.
Note: Refer to the textbook for a discussion of escape
sequences. These
are characters that can be inserted into strings and, when
printed, will
format the display neatly. An escape sequence for the tab
character can
be inserted to get a tabular form when printing. This tab
character is "t".
The LineItem class will have a toString( ) method that
concatenates
itemName, quantity, price, and total price—separated by tab
characters—and returns this new string. When printing an
object, the
toString( ) method will be implicitly called, which in this case,
will print a
string that will look something like:
Colgate Toothpaste qty 2 @ $2.99 $5.98
3. Build a Transaction class that will store information about
the items being
purchased in a single transaction. It should include a
customerID and
customerName. It should also include an ArrayList to hold
information about
each item that the customer is purchasing as part of the
transaction.
Note: You must use an ArrayList, not an array.
4. Build a TransactionTest class to test the application. The test
class should not
require any interaction with the user. It should verify the
correct operation of the
constructor and all methods in the Transaction class.
Specific Requirements for the Transaction Class
1. The Transaction class should have a constructor with two
parameters. The first
is an integer containing the customer’s ID and the second is a
String containing
the customer’s name.
2. There should be a method to allow the addition of a line item
to the transcript.
The three parameters for the addLineItem method will be (1) the
item name, (2)
the quantity, and (3) the single item price.
3. There should be a method to allow the updating of a line item
already in the
transaction. Notice that updating an item means changing the
quantity or price
(or both). The parameters for the updateItem method are also
(1) the item name,
(2) the quantity, and (3) the single item price. Notice that the
updating of a
© 2014 Laureate Education, Inc. Page 3 of 4
specific line item requires a search through the ArrayList to
find the desired
item. Anytime a search is done, the possibility exists that the
search will be
unsuccessful. It is often difficult to decide what action should
be taken when such
an "exception" occurs. Since exception handling is not covered
until later in this
textbook, make some arbitrary decisions for this project. If the
item to be updated
is not found, take the simplest action possible and do nothing.
Do not print an
error message to the screen. Simply leave the transaction
unchanged.
4. The transaction class needs a method called getTotalPrice to
return the total
price of the transaction.
5. There should also be a method to return information about a
specific line item. It
should return a single String object in the same format
described for the
LineItem class:
Colgate Toothpaste qty 2 @ $2.99 $5.98
Again, the possibility exists that the search for a specific line
item will fail. In this
instance, you should return a string containing a message
similar to this:
Colgate Toothpaste not found.
6. The final method needed is a toString method. It should
return the transaction
information in a single String object. It should use the
following format:
Customer ID : 12345
Customer Name : John Doe
Colgate Toothpaste qty 2 @ $2.99 $5.98
Bounty Paper Towels qty 1 @ $1.49 $1.49
Kleenex Tissue qty 1 @ $2.49 $2.49
Transaction Total $9.96
Notice that a newline character "n" can be inserted into the
middle of a string.
Ex.
int age = 30;
String temp = "John Doe n is " + age + "n" + " years
old";
The output would be:
John Doe
is 30
years old
© 2014 Laureate Education, Inc. Page 4 of 4
Notice also that "n" is a single character and could actually go
inside single or
double quotes, depending on the circumstances.
Here is a UML diagram for the Transaction class as described
above. Notice that
private instance variables and methods may be added, as
needed. For all public
methods use exactly the name given below.
Transaction
- lineItems : ArrayList<LineItem>
- customerID : int
- customerName : String
+ Transaction( int, String )
+ addLineItem( String, int, double )
+ updateItem( String, int, double )
+ getTotalPrice( ) : double
+ getLineItem( String ) : String
+ toString( ) : String
© 2014 Laureate Education, Inc. Page 1 of 5
Amusement Park Programming Project
Project Outcomes
1. Use the Java selection constructs (if and if else).
2. Use the Java iteration constructs (while, do, for).
3. Use Boolean variables and expressions to control iterations.
4. Use arrays or ArrayList for storing objects.
5. Proper design techniques.
Project Requirements
Your job is to implement a simple amusement park information
system that
keeps track of admission tickets and merchandise in the gift
shop. The
information system consists of three classes including a class to
model tickets, a
class to model gift shop merchandise, the amusement park, and
the amusement
park tester. The gift shop supports access to specific
merchandise in the park’s
gift shop and to purchase the merchandise or to order new
merchandise for the
gift shop. The UML diagram for each class (except the tester
class) is given
below.
1) Develop a simple class that models admission tickets. Each
admission is
described by several instance fields:
a. A ticket number as a long integer to identify the unique
ticket,
b. A ticket category represented as a String to store the category
of the
ticket (i.e. adult, child, senior),
c. A ticket holder represented as a String to store the name of
the person
who purchased the ticket,
d. A date represented as a Date to store the admission date for
the ticket,
e. A price represented as a double to store the price of the
ticket,
f. A purchase status represented as a boolean to indicate if the
ticket has
been purchased (or is reserved).
Ticket
-number : long
-category : String
-holder : String
-date : Date
-price : double
© 2014 Laureate Education, Inc. Page 2 of 5
In addition to these fields, the class has the following
constructors and
methods:
a. A parameterized constructor that initializes the attributes of a
ticket.
b. setPrice(double price) to change the price of a textbook.
c. changePurchaseStatus(boolean newStatus) to change the
purchase status of the ticket.
d. Accessor methods for all instance fields.
e. toString() to return a neatly formatted string that contains all
the
information stored in the instance fields.
2) Develop a simple class that models merchandise available in
the gift shop
such as t-shirts, sweatshirts, and stuffed animals. The class has
several
instance fields:
a. An ID as a long integer to identify the specific merchandise
item,
b. A category as a String to store the specific type of
merchandise,
c. A description as a String to store the description of the
merchandise,
d. A price represented as a double to store the price of the
merchandise,
e. An instock as a boolean to indicate if the merchandise is
instock or on-
order.
Valid values for category include "T-Shirt", "Sweatshirt", and
"Stuffed Animal",
as well as any additional category you choose to support. If
invalid values are
entered, an error message must be printed and the category
instance field
must be set to "UNKNOWN".
In addition to these attributes, the class has the following
constructors and
methods:
f. A parameterized constructor that initializes the attributes of a
merchandise item.
g. setPrice(double price) to change the price of the merchandise.
h. setInstock(boolean newStatus) to change the status of the
merchandise item.
i. Accessor methods for all instance fields.
j. toString() to return a neatly formatted string that contains all
the
information stored in the instance fields.
+Ticket (String, String, Date, double, boolean)
+setPrice(double)
+changePurchaseStatus(boolean)
+getNumber() : long
+getCategory() : String
+getHolder() : String
+getDate() : String
+getPrice() : double
+toString() : String
© 2014 Laureate Education, Inc. Page 3 of 5
Merchandise
-id : long
-category : String
-description : String
-price : double
-inStock : boolean
+Merchandise(String, String, String, double, boolean)
+setPrice(double)
+setInstock(boolean)
+getId() : String
+getCategory() : String
+getDescription() : String
+getPrice() : double
+getInstock() : boolean
+toString() : String
3) Develop class AmusementPark that keeps track of tickets and
gift shop
inventory. The AmusementPark uses two ArrayLists to store
Ticket and
Merchandise objects. The AmusementPark provides several
methods to
add merchandise to the gift shop and to access merchandise.
The following
UML diagram describes the class, the constructor, and the
methods:
AmusementPark
-tickets : ArrayList<Ticket>
-merchandise : ArrayList<Merchandise>
-name : String
+AmusementPark(String)
+getName() : String
+getTicketDates() : ArrayList<Date>
+getTickets(Date date) : int
+getTicket(long id) : Ticket
+getMerchandise() : ArrayList<Merchandise>
+getMerchandise(String category) : ArrayList<Merchandise>
+getMerchandise(long id) : Merchandise
+addTicket(Ticket)
+addMerchandise(Merchandise)
+buyMerchandise(String id)
+buyTicket(String id)
a. The class has three instance fields:
a. name, the name of the bookstore
b. tickets, an ArrayList<Ticket> storing Ticket objects
© 2014 Laureate Education, Inc. Page 4 of 5
c. merchandise, an ArrayList<Merchandise> storing
Merchandise objects
b. getName() returns the name of the bookstore.
c. getTicketDates() returns an ArrayList<Date> of all the dates
for which tickets are still available. If there are no tickets
available, an
empty list is returned.
d. getTickets (Date date) returns an integer indicating the
number
of tickets available for the specified date.
e. getTicket(long id) returns the Ticket that matches the
specified id. If there is no Ticket matching the given id, null is
returned.
f. getMerchandise()returns an ArrayList<Merchandise> of all
the inventory (in-stock and ordered). This method must create a
separate copy of the ArrayList before it returns the list. If there
are
no merchandise items in the AmusementPark, an empty list is
returned.
g. getMerchandise(String category) returns a list of
Merchandise objects whose category matches the specified
category. For example, if called with "T-shirt" the method
returns all
Merchandise objects with the category "T-shirt" as a new list.
This
method must create a new copy of an ArrayList that stores all
the
matched Merchandise objects. If no items in the
AmusementPark
match the given name, an empty list is returned.
h. getMerchandise(long id) returns the merchandise item that
matches the specified id. If there is no merchandise item
matching the
given id, null is returned.
i. addTicket(Ticket) adds a new Ticket to the inventory of the
AmusementPark.
j. addMerchandise(Merchandise) adds a new Merchandise to the
inventory of the AmusementPark.
k. buyMerchandise(String id) removes a Merchandise object
from the list of merchandise of the AmusementPark. If the id
does not
match any Merchandise object in the list, an exception is
thrown.
l. buyTicket(String id) removes a Ticket object from the list of
ticket items of the AmusementPark. If the id does not match any
Ticket object in the list, an exception is thrown.
4) Design a tester class called AmusementParkTester. The tester
class has a
main() method and tests the functionality of the class
AmusementPark as
follows:
a. Create AmusementPark and name it "Walden Amusement
Park".
b. Create a minimum of three Ticket objects and add them to the
bookstore.
© 2014 Laureate Education, Inc. Page 5 of 5
c. Create Apparel objects, at least two of each category, and add
them
to the AmusementPark.
d. Set up a loop to:
i. Display a short menu that allows a user to perform different
actions in the gift shop such as looking up tickets or
merchandise or purchasing items. Use all of the accessor
methods in the AmusementPark to access specific items. Use
the given methods to make purchases.
ii. Prompt the user for a specific action.
iii. Depending on the specific action prompt the user for
additional
input such as the id of a ticket or merchandise category, etc.
You might want to use static methods in main() to handle each
menu item separately.
iv. Perform the action and display results such as the list of
merchandise that the user has requested. Use the toString()
method to display AmusementPark items on the screen.
v. Prompt the user for continued access to the AmusementPark
or to end the program.
Your program should handle input errors gracefully. For
example, if a particular
ticket is searched and not found, the program should display a
message such as
"Selected ticket not found." Feel free to experiment with the
tester program in
order to develop a more useful program.
Implementation Notes:
1) All accessor methods in AmusementPark must create a new
ArrayList
to copy objects into the new list. This requires loops to access
objects
from the corresponding instance fields and adding them to the
new
ArrayList.
2) Proper error handling is essential for this project.
3) Javadoc must be used to document AmusementPark, Ticket,
and
Merchandise.
Submission Requirements:
1. Your project submission should have four files for this
assignment:
a. Ticket.java - The Ticket class,
b. Merchandise.java - The Merchandise class,
c. AmusementPark.java - The AmusementPark class,
d. AmusementParkTester.java - A driver program for testing
your
AmusementPark class.
2. Remember to compile and run your program one last time
before you
submit it

More Related Content

Similar to © 2014 Laureate Education, Inc. Page 1 of 4 Retail Trans.docx

ITECH 2100 Programming 2 School of Science, Information Te.docx
ITECH 2100 Programming 2 School of Science, Information Te.docxITECH 2100 Programming 2 School of Science, Information Te.docx
ITECH 2100 Programming 2 School of Science, Information Te.docxchristiandean12115
 
Exercise1[5points]Create the following classe
Exercise1[5points]Create the following classeExercise1[5points]Create the following classe
Exercise1[5points]Create the following classemecklenburgstrelitzh
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2ppJ. C.
 
Data Types & Objects .pptx
Data Types & Objects .pptxData Types & Objects .pptx
Data Types & Objects .pptxNayyabMirTahir
 
Program Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docxProgram Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docxVictormxrPiperc
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfeyebolloptics
 
Text field and textarea
Text field and textareaText field and textarea
Text field and textareamyrajendra
 
EE660 Project_sl_final
EE660 Project_sl_finalEE660 Project_sl_final
EE660 Project_sl_finalShanglin Yang
 
Object Oriented Programming Assignment 4
Object Oriented Programming Assignment 4Object Oriented Programming Assignment 4
Object Oriented Programming Assignment 4Kasun Ranga Wijeweera
 
computer notes - Reference variables ii
computer notes - Reference variables iicomputer notes - Reference variables ii
computer notes - Reference variables iiecomputernotes
 
Lecture 6 polymorphism
Lecture 6 polymorphismLecture 6 polymorphism
Lecture 6 polymorphismthe_wumberlog
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in JavaSpotle.ai
 

Similar to © 2014 Laureate Education, Inc. Page 1 of 4 Retail Trans.docx (18)

ITECH 2100 Programming 2 School of Science, Information Te.docx
ITECH 2100 Programming 2 School of Science, Information Te.docxITECH 2100 Programming 2 School of Science, Information Te.docx
ITECH 2100 Programming 2 School of Science, Information Te.docx
 
Intake 38 3
Intake 38 3Intake 38 3
Intake 38 3
 
Exercise1[5points]Create the following classe
Exercise1[5points]Create the following classeExercise1[5points]Create the following classe
Exercise1[5points]Create the following classe
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2pp
 
Data Types & Objects .pptx
Data Types & Objects .pptxData Types & Objects .pptx
Data Types & Objects .pptx
 
Program Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docxProgram Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docx
 
Online CPP Homework Help
Online CPP Homework HelpOnline CPP Homework Help
Online CPP Homework Help
 
E-Bazaar
E-BazaarE-Bazaar
E-Bazaar
 
Task 1
Task 1Task 1
Task 1
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdf
 
Text field and textarea
Text field and textareaText field and textarea
Text field and textarea
 
EE660 Project_sl_final
EE660 Project_sl_finalEE660 Project_sl_final
EE660 Project_sl_final
 
Object Oriented Programming Assignment 4
Object Oriented Programming Assignment 4Object Oriented Programming Assignment 4
Object Oriented Programming Assignment 4
 
Lect15
Lect15Lect15
Lect15
 
I x scripting
I x scriptingI x scripting
I x scripting
 
computer notes - Reference variables ii
computer notes - Reference variables iicomputer notes - Reference variables ii
computer notes - Reference variables ii
 
Lecture 6 polymorphism
Lecture 6 polymorphismLecture 6 polymorphism
Lecture 6 polymorphism
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 

More from LynellBull52

· · · Must be a foreign film with subtitles· Provide you wit.docx
· · · Must be a foreign film with subtitles· Provide you wit.docx· · · Must be a foreign film with subtitles· Provide you wit.docx
· · · Must be a foreign film with subtitles· Provide you wit.docxLynellBull52
 
·  Identify the stakeholders and how they were affected by Heene.docx
·  Identify the stakeholders and how they were affected by Heene.docx·  Identify the stakeholders and how they were affected by Heene.docx
·  Identify the stakeholders and how they were affected by Heene.docxLynellBull52
 
· · Re WEEK ONE - DISCUSSION QUESTION # 2posted by DONALD DEN.docx
· · Re WEEK ONE - DISCUSSION QUESTION # 2posted by DONALD DEN.docx· · Re WEEK ONE - DISCUSSION QUESTION # 2posted by DONALD DEN.docx
· · Re WEEK ONE - DISCUSSION QUESTION # 2posted by DONALD DEN.docxLynellBull52
 
· Week 3 AssignmentGovernment and Not-For-Profit AccountingVal.docx
· Week 3 AssignmentGovernment and Not-For-Profit AccountingVal.docx· Week 3 AssignmentGovernment and Not-For-Profit AccountingVal.docx
· Week 3 AssignmentGovernment and Not-For-Profit AccountingVal.docxLynellBull52
 
· Week 10 Assignment 2 SubmissionStudents, please view the.docx
· Week 10 Assignment 2 SubmissionStudents, please view the.docx· Week 10 Assignment 2 SubmissionStudents, please view the.docx
· Week 10 Assignment 2 SubmissionStudents, please view the.docxLynellBull52
 
· Write in paragraph format (no lists, bullets, or numbers).· .docx
· Write in paragraph format (no lists, bullets, or numbers).· .docx· Write in paragraph format (no lists, bullets, or numbers).· .docx
· Write in paragraph format (no lists, bullets, or numbers).· .docxLynellBull52
 
· WEEK 1 Databases and SecurityLesson· Databases and Security.docx
· WEEK 1 Databases and SecurityLesson· Databases and Security.docx· WEEK 1 Databases and SecurityLesson· Databases and Security.docx
· WEEK 1 Databases and SecurityLesson· Databases and Security.docxLynellBull52
 
· Unit 4 Citizen RightsINTRODUCTIONIn George Orwells Animal.docx
· Unit 4 Citizen RightsINTRODUCTIONIn George Orwells Animal.docx· Unit 4 Citizen RightsINTRODUCTIONIn George Orwells Animal.docx
· Unit 4 Citizen RightsINTRODUCTIONIn George Orwells Animal.docxLynellBull52
 
· Unit Interface-User Interaction· Assignment Objectives Em.docx
· Unit  Interface-User Interaction· Assignment Objectives Em.docx· Unit  Interface-User Interaction· Assignment Objectives Em.docx
· Unit Interface-User Interaction· Assignment Objectives Em.docxLynellBull52
 
· The Victims’ Rights MovementWrite a 2 page paper.  Address the.docx
· The Victims’ Rights MovementWrite a 2 page paper.  Address the.docx· The Victims’ Rights MovementWrite a 2 page paper.  Address the.docx
· The Victims’ Rights MovementWrite a 2 page paper.  Address the.docxLynellBull52
 
· Question 1· · How does internal environmental analy.docx
· Question 1· ·        How does internal environmental analy.docx· Question 1· ·        How does internal environmental analy.docx
· Question 1· · How does internal environmental analy.docxLynellBull52
 
· Question 1Question 192 out of 2 pointsWhat file in the.docx
· Question 1Question 192 out of 2 pointsWhat file in the.docx· Question 1Question 192 out of 2 pointsWhat file in the.docx
· Question 1Question 192 out of 2 pointsWhat file in the.docxLynellBull52
 
· Question 15 out of 5 pointsWhen psychologists discuss .docx
· Question 15 out of 5 pointsWhen psychologists discuss .docx· Question 15 out of 5 pointsWhen psychologists discuss .docx
· Question 15 out of 5 pointsWhen psychologists discuss .docxLynellBull52
 
· Question 1 2 out of 2 pointsWhich of the following i.docx
· Question 1 2 out of 2 pointsWhich of the following i.docx· Question 1 2 out of 2 pointsWhich of the following i.docx
· Question 1 2 out of 2 pointsWhich of the following i.docxLynellBull52
 
· Processed on 09-Dec-2014 901 PM CST · ID 488406360 · Word .docx
· Processed on 09-Dec-2014 901 PM CST · ID 488406360 · Word .docx· Processed on 09-Dec-2014 901 PM CST · ID 488406360 · Word .docx
· Processed on 09-Dec-2014 901 PM CST · ID 488406360 · Word .docxLynellBull52
 
· Strengths Public Recognition of OrganizationOverall Positive P.docx
· Strengths Public Recognition of OrganizationOverall Positive P.docx· Strengths Public Recognition of OrganizationOverall Positive P.docx
· Strengths Public Recognition of OrganizationOverall Positive P.docxLynellBull52
 
· Part I Key Case SummaryThis case discusses the Union Carbid.docx
· Part I Key Case SummaryThis case discusses the Union Carbid.docx· Part I Key Case SummaryThis case discusses the Union Carbid.docx
· Part I Key Case SummaryThis case discusses the Union Carbid.docxLynellBull52
 
· Perceptual process is a process through manager receive organize.docx
· Perceptual process is a process through manager receive organize.docx· Perceptual process is a process through manager receive organize.docx
· Perceptual process is a process through manager receive organize.docxLynellBull52
 
· Performance Critique Assignment· During the first month of.docx
· Performance Critique Assignment· During the first month of.docx· Performance Critique Assignment· During the first month of.docx
· Performance Critique Assignment· During the first month of.docxLynellBull52
 
· Please read the following article excerpt, and view the video cl.docx
· Please read the following article excerpt, and view the video cl.docx· Please read the following article excerpt, and view the video cl.docx
· Please read the following article excerpt, and view the video cl.docxLynellBull52
 

More from LynellBull52 (20)

· · · Must be a foreign film with subtitles· Provide you wit.docx
· · · Must be a foreign film with subtitles· Provide you wit.docx· · · Must be a foreign film with subtitles· Provide you wit.docx
· · · Must be a foreign film with subtitles· Provide you wit.docx
 
·  Identify the stakeholders and how they were affected by Heene.docx
·  Identify the stakeholders and how they were affected by Heene.docx·  Identify the stakeholders and how they were affected by Heene.docx
·  Identify the stakeholders and how they were affected by Heene.docx
 
· · Re WEEK ONE - DISCUSSION QUESTION # 2posted by DONALD DEN.docx
· · Re WEEK ONE - DISCUSSION QUESTION # 2posted by DONALD DEN.docx· · Re WEEK ONE - DISCUSSION QUESTION # 2posted by DONALD DEN.docx
· · Re WEEK ONE - DISCUSSION QUESTION # 2posted by DONALD DEN.docx
 
· Week 3 AssignmentGovernment and Not-For-Profit AccountingVal.docx
· Week 3 AssignmentGovernment and Not-For-Profit AccountingVal.docx· Week 3 AssignmentGovernment and Not-For-Profit AccountingVal.docx
· Week 3 AssignmentGovernment and Not-For-Profit AccountingVal.docx
 
· Week 10 Assignment 2 SubmissionStudents, please view the.docx
· Week 10 Assignment 2 SubmissionStudents, please view the.docx· Week 10 Assignment 2 SubmissionStudents, please view the.docx
· Week 10 Assignment 2 SubmissionStudents, please view the.docx
 
· Write in paragraph format (no lists, bullets, or numbers).· .docx
· Write in paragraph format (no lists, bullets, or numbers).· .docx· Write in paragraph format (no lists, bullets, or numbers).· .docx
· Write in paragraph format (no lists, bullets, or numbers).· .docx
 
· WEEK 1 Databases and SecurityLesson· Databases and Security.docx
· WEEK 1 Databases and SecurityLesson· Databases and Security.docx· WEEK 1 Databases and SecurityLesson· Databases and Security.docx
· WEEK 1 Databases and SecurityLesson· Databases and Security.docx
 
· Unit 4 Citizen RightsINTRODUCTIONIn George Orwells Animal.docx
· Unit 4 Citizen RightsINTRODUCTIONIn George Orwells Animal.docx· Unit 4 Citizen RightsINTRODUCTIONIn George Orwells Animal.docx
· Unit 4 Citizen RightsINTRODUCTIONIn George Orwells Animal.docx
 
· Unit Interface-User Interaction· Assignment Objectives Em.docx
· Unit  Interface-User Interaction· Assignment Objectives Em.docx· Unit  Interface-User Interaction· Assignment Objectives Em.docx
· Unit Interface-User Interaction· Assignment Objectives Em.docx
 
· The Victims’ Rights MovementWrite a 2 page paper.  Address the.docx
· The Victims’ Rights MovementWrite a 2 page paper.  Address the.docx· The Victims’ Rights MovementWrite a 2 page paper.  Address the.docx
· The Victims’ Rights MovementWrite a 2 page paper.  Address the.docx
 
· Question 1· · How does internal environmental analy.docx
· Question 1· ·        How does internal environmental analy.docx· Question 1· ·        How does internal environmental analy.docx
· Question 1· · How does internal environmental analy.docx
 
· Question 1Question 192 out of 2 pointsWhat file in the.docx
· Question 1Question 192 out of 2 pointsWhat file in the.docx· Question 1Question 192 out of 2 pointsWhat file in the.docx
· Question 1Question 192 out of 2 pointsWhat file in the.docx
 
· Question 15 out of 5 pointsWhen psychologists discuss .docx
· Question 15 out of 5 pointsWhen psychologists discuss .docx· Question 15 out of 5 pointsWhen psychologists discuss .docx
· Question 15 out of 5 pointsWhen psychologists discuss .docx
 
· Question 1 2 out of 2 pointsWhich of the following i.docx
· Question 1 2 out of 2 pointsWhich of the following i.docx· Question 1 2 out of 2 pointsWhich of the following i.docx
· Question 1 2 out of 2 pointsWhich of the following i.docx
 
· Processed on 09-Dec-2014 901 PM CST · ID 488406360 · Word .docx
· Processed on 09-Dec-2014 901 PM CST · ID 488406360 · Word .docx· Processed on 09-Dec-2014 901 PM CST · ID 488406360 · Word .docx
· Processed on 09-Dec-2014 901 PM CST · ID 488406360 · Word .docx
 
· Strengths Public Recognition of OrganizationOverall Positive P.docx
· Strengths Public Recognition of OrganizationOverall Positive P.docx· Strengths Public Recognition of OrganizationOverall Positive P.docx
· Strengths Public Recognition of OrganizationOverall Positive P.docx
 
· Part I Key Case SummaryThis case discusses the Union Carbid.docx
· Part I Key Case SummaryThis case discusses the Union Carbid.docx· Part I Key Case SummaryThis case discusses the Union Carbid.docx
· Part I Key Case SummaryThis case discusses the Union Carbid.docx
 
· Perceptual process is a process through manager receive organize.docx
· Perceptual process is a process through manager receive organize.docx· Perceptual process is a process through manager receive organize.docx
· Perceptual process is a process through manager receive organize.docx
 
· Performance Critique Assignment· During the first month of.docx
· Performance Critique Assignment· During the first month of.docx· Performance Critique Assignment· During the first month of.docx
· Performance Critique Assignment· During the first month of.docx
 
· Please read the following article excerpt, and view the video cl.docx
· Please read the following article excerpt, and view the video cl.docx· Please read the following article excerpt, and view the video cl.docx
· Please read the following article excerpt, and view the video cl.docx
 

Recently uploaded

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 

Recently uploaded (20)

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 

© 2014 Laureate Education, Inc. Page 1 of 4 Retail Trans.docx

  • 1. © 2014 Laureate Education, Inc. Page 1 of 4 Retail Transaction Programming Project Project Requirements: 1. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual line item of merchandise that a customer is purchasing. The Transaction class will combine several LineItem objects and calculate an overall total price for the line item within the transaction. There will also be two test classes, one for the LineItem class and one for the Transaction class. 2. Design and build a LineItem class. This class will have three instance variables. There will be an itemName variable that will hold the identification of the line item (such as, "Colgate Toothpaste"); a quantity variable that will hold the quantity of the item being purchased; and a price variable that will hold the retail price of the item. The LineItem class should have a constructor, accessors
  • 2. for the instance variables, a method to compute the total price for the line item, a method to update the quantity, and a method to convert the state of the object to a string. Using Unified Modeling Language (UML), the class diagram looks like this: LineItem - itemName : String - quantity : int - price : double + LineItem( String, int, double ) + getName( ) : String + getQuantity( ) : int + getPrice( ) : double + getTotalPrice( ) : double + setQuantity( int ) + setPrice( double ) + toString( ) : String
  • 3. a. The constructor will assign the first parameter to the instance variable itemName, the second parameter to the instance variable quantity, and the third parameter to the instance variable price. b. The class will have three accessor methods—getName( ), getQuantity( ), and getPrice( )—that will return the value of each respective instance variable. © 2014 Laureate Education, Inc. Page 2 of 4 c. The class will have two mutator methods, setQuantity( int ) and setPrice( double ), that will update the quantity and price, respectively, of the item associated with the line of the transaction. d. The method getTotalPrice( ) handles the conversion of the quantity and price into a total price for the line item. e. The method toString( ) allows access to the state of the object in a printable or readable form. It converts the variables to a single string that is neatly formatted.
  • 4. Note: Refer to the textbook for a discussion of escape sequences. These are characters that can be inserted into strings and, when printed, will format the display neatly. An escape sequence for the tab character can be inserted to get a tabular form when printing. This tab character is "t". The LineItem class will have a toString( ) method that concatenates itemName, quantity, price, and total price—separated by tab characters—and returns this new string. When printing an object, the toString( ) method will be implicitly called, which in this case, will print a string that will look something like: Colgate Toothpaste qty 2 @ $2.99 $5.98 3. Build a Transaction class that will store information about the items being purchased in a single transaction. It should include a customerID and customerName. It should also include an ArrayList to hold information about each item that the customer is purchasing as part of the transaction. Note: You must use an ArrayList, not an array.
  • 5. 4. Build a TransactionTest class to test the application. The test class should not require any interaction with the user. It should verify the correct operation of the constructor and all methods in the Transaction class. Specific Requirements for the Transaction Class 1. The Transaction class should have a constructor with two parameters. The first is an integer containing the customer’s ID and the second is a String containing the customer’s name. 2. There should be a method to allow the addition of a line item to the transcript. The three parameters for the addLineItem method will be (1) the item name, (2) the quantity, and (3) the single item price. 3. There should be a method to allow the updating of a line item already in the transaction. Notice that updating an item means changing the quantity or price (or both). The parameters for the updateItem method are also (1) the item name, (2) the quantity, and (3) the single item price. Notice that the updating of a © 2014 Laureate Education, Inc. Page 3 of 4 specific line item requires a search through the ArrayList to find the desired
  • 6. item. Anytime a search is done, the possibility exists that the search will be unsuccessful. It is often difficult to decide what action should be taken when such an "exception" occurs. Since exception handling is not covered until later in this textbook, make some arbitrary decisions for this project. If the item to be updated is not found, take the simplest action possible and do nothing. Do not print an error message to the screen. Simply leave the transaction unchanged. 4. The transaction class needs a method called getTotalPrice to return the total price of the transaction. 5. There should also be a method to return information about a specific line item. It should return a single String object in the same format described for the LineItem class: Colgate Toothpaste qty 2 @ $2.99 $5.98 Again, the possibility exists that the search for a specific line item will fail. In this instance, you should return a string containing a message similar to this: Colgate Toothpaste not found.
  • 7. 6. The final method needed is a toString method. It should return the transaction information in a single String object. It should use the following format: Customer ID : 12345 Customer Name : John Doe Colgate Toothpaste qty 2 @ $2.99 $5.98 Bounty Paper Towels qty 1 @ $1.49 $1.49 Kleenex Tissue qty 1 @ $2.49 $2.49 Transaction Total $9.96 Notice that a newline character "n" can be inserted into the middle of a string. Ex. int age = 30; String temp = "John Doe n is " + age + "n" + " years old"; The output would be: John Doe is 30 years old
  • 8. © 2014 Laureate Education, Inc. Page 4 of 4 Notice also that "n" is a single character and could actually go inside single or double quotes, depending on the circumstances. Here is a UML diagram for the Transaction class as described above. Notice that private instance variables and methods may be added, as needed. For all public methods use exactly the name given below. Transaction - lineItems : ArrayList<LineItem> - customerID : int - customerName : String + Transaction( int, String ) + addLineItem( String, int, double ) + updateItem( String, int, double ) + getTotalPrice( ) : double
  • 9. + getLineItem( String ) : String + toString( ) : String © 2014 Laureate Education, Inc. Page 1 of 5 Amusement Park Programming Project Project Outcomes 1. Use the Java selection constructs (if and if else). 2. Use the Java iteration constructs (while, do, for). 3. Use Boolean variables and expressions to control iterations. 4. Use arrays or ArrayList for storing objects. 5. Proper design techniques. Project Requirements Your job is to implement a simple amusement park information system that keeps track of admission tickets and merchandise in the gift shop. The information system consists of three classes including a class to model tickets, a class to model gift shop merchandise, the amusement park, and the amusement park tester. The gift shop supports access to specific
  • 10. merchandise in the park’s gift shop and to purchase the merchandise or to order new merchandise for the gift shop. The UML diagram for each class (except the tester class) is given below. 1) Develop a simple class that models admission tickets. Each admission is described by several instance fields: a. A ticket number as a long integer to identify the unique ticket, b. A ticket category represented as a String to store the category of the ticket (i.e. adult, child, senior), c. A ticket holder represented as a String to store the name of the person who purchased the ticket, d. A date represented as a Date to store the admission date for the ticket, e. A price represented as a double to store the price of the ticket, f. A purchase status represented as a boolean to indicate if the ticket has been purchased (or is reserved). Ticket -number : long -category : String
  • 11. -holder : String -date : Date -price : double © 2014 Laureate Education, Inc. Page 2 of 5 In addition to these fields, the class has the following constructors and methods: a. A parameterized constructor that initializes the attributes of a ticket. b. setPrice(double price) to change the price of a textbook. c. changePurchaseStatus(boolean newStatus) to change the purchase status of the ticket. d. Accessor methods for all instance fields. e. toString() to return a neatly formatted string that contains all the information stored in the instance fields. 2) Develop a simple class that models merchandise available in the gift shop such as t-shirts, sweatshirts, and stuffed animals. The class has several instance fields:
  • 12. a. An ID as a long integer to identify the specific merchandise item, b. A category as a String to store the specific type of merchandise, c. A description as a String to store the description of the merchandise, d. A price represented as a double to store the price of the merchandise, e. An instock as a boolean to indicate if the merchandise is instock or on- order. Valid values for category include "T-Shirt", "Sweatshirt", and "Stuffed Animal", as well as any additional category you choose to support. If invalid values are entered, an error message must be printed and the category instance field must be set to "UNKNOWN". In addition to these attributes, the class has the following constructors and methods: f. A parameterized constructor that initializes the attributes of a merchandise item. g. setPrice(double price) to change the price of the merchandise. h. setInstock(boolean newStatus) to change the status of the merchandise item. i. Accessor methods for all instance fields. j. toString() to return a neatly formatted string that contains all the
  • 13. information stored in the instance fields. +Ticket (String, String, Date, double, boolean) +setPrice(double) +changePurchaseStatus(boolean) +getNumber() : long +getCategory() : String +getHolder() : String +getDate() : String +getPrice() : double +toString() : String © 2014 Laureate Education, Inc. Page 3 of 5 Merchandise -id : long -category : String -description : String
  • 14. -price : double -inStock : boolean +Merchandise(String, String, String, double, boolean) +setPrice(double) +setInstock(boolean) +getId() : String +getCategory() : String +getDescription() : String +getPrice() : double +getInstock() : boolean +toString() : String 3) Develop class AmusementPark that keeps track of tickets and gift shop inventory. The AmusementPark uses two ArrayLists to store Ticket and Merchandise objects. The AmusementPark provides several methods to add merchandise to the gift shop and to access merchandise. The following
  • 15. UML diagram describes the class, the constructor, and the methods: AmusementPark -tickets : ArrayList<Ticket> -merchandise : ArrayList<Merchandise> -name : String +AmusementPark(String) +getName() : String +getTicketDates() : ArrayList<Date> +getTickets(Date date) : int +getTicket(long id) : Ticket +getMerchandise() : ArrayList<Merchandise> +getMerchandise(String category) : ArrayList<Merchandise> +getMerchandise(long id) : Merchandise +addTicket(Ticket) +addMerchandise(Merchandise) +buyMerchandise(String id) +buyTicket(String id)
  • 16. a. The class has three instance fields: a. name, the name of the bookstore b. tickets, an ArrayList<Ticket> storing Ticket objects © 2014 Laureate Education, Inc. Page 4 of 5 c. merchandise, an ArrayList<Merchandise> storing Merchandise objects b. getName() returns the name of the bookstore. c. getTicketDates() returns an ArrayList<Date> of all the dates for which tickets are still available. If there are no tickets available, an empty list is returned. d. getTickets (Date date) returns an integer indicating the number of tickets available for the specified date. e. getTicket(long id) returns the Ticket that matches the specified id. If there is no Ticket matching the given id, null is returned. f. getMerchandise()returns an ArrayList<Merchandise> of all the inventory (in-stock and ordered). This method must create a
  • 17. separate copy of the ArrayList before it returns the list. If there are no merchandise items in the AmusementPark, an empty list is returned. g. getMerchandise(String category) returns a list of Merchandise objects whose category matches the specified category. For example, if called with "T-shirt" the method returns all Merchandise objects with the category "T-shirt" as a new list. This method must create a new copy of an ArrayList that stores all the matched Merchandise objects. If no items in the AmusementPark match the given name, an empty list is returned. h. getMerchandise(long id) returns the merchandise item that matches the specified id. If there is no merchandise item matching the given id, null is returned. i. addTicket(Ticket) adds a new Ticket to the inventory of the AmusementPark. j. addMerchandise(Merchandise) adds a new Merchandise to the
  • 18. inventory of the AmusementPark. k. buyMerchandise(String id) removes a Merchandise object from the list of merchandise of the AmusementPark. If the id does not match any Merchandise object in the list, an exception is thrown. l. buyTicket(String id) removes a Ticket object from the list of ticket items of the AmusementPark. If the id does not match any Ticket object in the list, an exception is thrown. 4) Design a tester class called AmusementParkTester. The tester class has a main() method and tests the functionality of the class AmusementPark as follows: a. Create AmusementPark and name it "Walden Amusement Park". b. Create a minimum of three Ticket objects and add them to the bookstore. © 2014 Laureate Education, Inc. Page 5 of 5 c. Create Apparel objects, at least two of each category, and add
  • 19. them to the AmusementPark. d. Set up a loop to: i. Display a short menu that allows a user to perform different actions in the gift shop such as looking up tickets or merchandise or purchasing items. Use all of the accessor methods in the AmusementPark to access specific items. Use the given methods to make purchases. ii. Prompt the user for a specific action. iii. Depending on the specific action prompt the user for additional input such as the id of a ticket or merchandise category, etc. You might want to use static methods in main() to handle each menu item separately. iv. Perform the action and display results such as the list of merchandise that the user has requested. Use the toString() method to display AmusementPark items on the screen. v. Prompt the user for continued access to the AmusementPark or to end the program. Your program should handle input errors gracefully. For example, if a particular ticket is searched and not found, the program should display a message such as "Selected ticket not found." Feel free to experiment with the
  • 20. tester program in order to develop a more useful program. Implementation Notes: 1) All accessor methods in AmusementPark must create a new ArrayList to copy objects into the new list. This requires loops to access objects from the corresponding instance fields and adding them to the new ArrayList. 2) Proper error handling is essential for this project. 3) Javadoc must be used to document AmusementPark, Ticket, and Merchandise. Submission Requirements: 1. Your project submission should have four files for this assignment: a. Ticket.java - The Ticket class, b. Merchandise.java - The Merchandise class, c. AmusementPark.java - The AmusementPark class, d. AmusementParkTester.java - A driver program for testing your AmusementPark class.
  • 21. 2. Remember to compile and run your program one last time before you submit it