Develop a program to emulate a purchase transaction

Assignment Help JAVA Programming
Reference no: EM13861453

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.

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.

Reference no: EM13861453

Questions Cloud

Explain the innkeeper duty in this case : Explain the innkeeper's duty in this case. Summarize the trial court's decision of innkeeper negligence or not. Explain how the court arrived at that conclusion. Speculate whether or not the innkeeper likely would be held liable for breach of duty un..
Types of racism that african americans in cleveland : Could you also mention the types of racism that African Americans in Cleveland, OH dealt with the first half of the 1900s...and what successes came out of this city besides Ms. Hunter?
Incremental analysis for the special order : In September, Leno Company receives a special order for 24,700 toasters at $7.8 each from Centro Company of Ciudad Juarez. Acceptance of the order would result in an additional $3,000 of shipping costs but no increase in fixed operating expenses. ..
What are expected frequencies for categories of potato chips : What are the expected frequencies for the three categories of potato chips? Compute a Mann-Whitney U test on these data.
Develop a program to emulate a purchase transaction : 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
How the documents help us understand major events : The journal option is similar to the essay, except that you will be making several observations and reflections rather than developing one main point. Also, it is longer. Consider how the documents help us understand major events and ideas in the..
What impact will the policy in part a have on the market : What impact will the policy in part A have on the market? Illustrate this with a diagram. Use the market for skimmed milk as a guide. Assume the equilibrium price is €1,000 per ton.
Examine a current event political situation : Examine a current event political situation
Define empathy and explain why it is important for effective : Define empathy and explain why it is important for effective communication.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Creates a professorraing class

Write a program that creates a professorRaing class consisting of professor ID and three ratings. The three ratings are used to evaluate easiness, helpfullness, and clarity. In a separate implementation class, allow the user to enter the values.

  Design an adt for a two-color

Design an ADT for a two-color, double-stack ADT that consists of two stacks one "red" and one "blue" and has as its operations color-coded versions of the regular stack ADT operations.

  Create a simple shopping cart application

Create a simple shopping cart application. Display a list of books as an h:selectOneRadio element. When the user submits the form, store the user's selection in a SessionScoped managed bean

  Update your website to include a simple web form

Update your website to include a simple web form as discussed in your design document. Use JavaScript to validate the form contents and display the results of that validation to the user in a popup window

  Which method will a web browser call on a new applet

Which method will a web browser call on a new applet? What would happen if "String[]args" is not included as argument in the main method

  Write an application that enables users to enter student ID

Write an application that enables users to enter student ID and three exam scores. Provide a method to compute and returnthe overall exam average.  Provide another method that prints all scores and the average value formatted with no digits to the ri..

  Write a simple tester program

Implement a class named Friend which extends the Contact class. The Friend class should have a field that represents the friend's birthday. For simplicity, the birthdate can be represented with a String.

  Write a class named retailitem

Write a class named RetailItem that holds data about an item in a retail store. The class should have the given member variables:

  Write down a java program that implements a stack of

write a java program which implements a stack of integers. an integer should only be pushed into the stack if it is

  Create at least two vectors and demonstrate the use of each

Create a separate class, VectorTest, that will demonstrate the use of your Vector class. You must create at least two vectors, and demonstrate the use of each method. When you demonstrate the use of each method, print the results to the console ..

  Create a driver class in java

Your project is to create a driver class that uses SuperJavaIceCreamClass.

  Java programming-days alive calculator

The context for this assignment (all parts) is a ‘Days Alive Calculator' - a small desktop applicationfor calculating the number of days someone has been alive based on the date of birth and a seconddate, which may be today's date or some other date.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd