Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

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

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M92075928
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Programming Language

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As