Develop program emulate purchase transaction at retail store

Assignment Help Programming Languages
Reference no: EM131321327

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.

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 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

Reference no: EM131321327

Questions Cloud

Semi-circular detour around the origin : An in?nitely long wire carries a current I along the x-axis, and is bent so as to have a semi-circular detour around the origin, with radius R. Determine B at the origin.
How could we use our understanding of what the test x : Our data- ow analyses so far do not take advantage of the semantics of conditionals.
Subtract the cash flows of opportunity : Consider two mutually exclusive projects A & B. If you subtract the cash flows of opportunity B from the cash flows of opportunity A, then you should: An NPV graph
Uniformly distributed across the cross section of the wire : A cylindrical wire carries a steady total current I, uniformly distributed across the cross section of the wire. If the radius of the wire is R, determine the magnetic ?eld B inside and outside the wire.Consider the permeability of the wire to be t..
Develop program emulate purchase transaction at retail store : 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.
What is the current cost of special wedding : You are planning a special wedding three years from today. You don’t know who your spouse will be but you do know that you are saving $25,000 today and $35,000 one year from today for this purpose. You also plan to pay the final $45,000 of costs on y..
Define and describe a project net present value : What is the domestic and global markets for food service disposable packaging? Define and describe a project's Net Present Value. Describe how Net Present Value is used to choose among projects in the capital budgeting process. Define capital budgeti..
Classes in the insurance underwritting process : how do you feel about being grouped into classes in the insurance underwritting process? do you feel that insurance companies should treat all people alike?
Considering offering one hour photo developing : Food For Less (FFL), a grocery store, is considering offering one hour photo developing in their store. The firm expects that sales from the new one hour machine will be $150,000 per year. FFL currently offers overnight film processing with annual sa..

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a script to declares and sets variable

Write a script that declares and sets a variable thats equal to the total outstanding balance due. If that balance due is greater than $10,000.00.

  Write program to match master and transaction methods

When writing a program to match master and transaction methods, what should happen when the value of the master key is equal to the transaction key?

  Create logic for program to enter each household size

Create logic for a program that allows a user to enter each household size and find out the mean and median household size in Marengo.

  Write a program that display amount of discount on item

Write a program that asks the user to enter number of packages purchased. Program must then display amount of the discount (if any) and total amount of the purchase after the discount.

  Create the logic for a program that accepts input values

Create the logic for a program that accepts input values for the projected cost of a vacation and the number of month until vacation. Pass both values to a method that displays the amount you must save per month to achieve your goal.

  Write assignment statement with one arithmetic operator

Write a simple assignment statement with one arithmetic operator in some language you know. For each component of the statement.

  Problem analysis chart - flowchart

One of your smaller customers' needs your help writing a program. Your customer has an e-commerce Web site but wants to avoid being sued for allowing children to make purchases without the authorization of their parents

  Implement a program that prompts the user for an integer

Implement a program that prompts the user for an integer n and prints the nth Fibonacci number, using the above algorithm.

  Prepare function for one integer parameter-returns integer

Prepare the C++ function which needs one integer parameter and returns the integer value. Function will double value passed to it and return doubled value.

  Create internal representation of polynomial is array

Create class Polynomial. The internal representation of a Polynomial is an array of terms. Each term contains a coefficient and an exponent.

  Create program to read file calculate numbers of single men

Create a program to read through file and calculate numbers of married men, single men, married women and single women.

  Create classes essential to create service quote

Create classes essential to create service quote. Write the application program which will use classes to create the objects and output the service quote.

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