Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. You will implement two public classes: the Mothclass, and the MothTester class. The MothTester class contains the main method. 2. You will implement two

1. You will implement two public classes: the Mothclass, and the MothTester class. The MothTester class contains the main method.

2. You will implement two public classes: the Message class, and the MessageTester class. The MessageTester class contains the main method. The Message class uses an ArrayList to hold the lines of the message body

3. You will implement two public classes: the Mailbox class, and the MailboxTester class. You will also need the Message class from Programming Assignment 4. The MailboxTester class contains the main method. The Mailbox class uses an ArrayList to hold the messages in a mailbox.

4. Implement the following interface and classes:

IDiscountPolicy

BulkDiscount

BuyNItemsGetOneFree

CombinedDiscount

DiscountTester

IDiscountPolicy is an interface. IDiscountPolicy has singe method computeDiscount. computeDiscount returns a double. The double represents the discount amount for a given number of items. computeDiscount has two parameters. int count indicates the number of items. double itemCost is the cost of a single item.

BulkDiscount implements the IDiscountPolicy interface. The constructor has two parameters. int minimum specifies the minimum number of items need to get the discount. double percent is the discount percent. The computeDiscount method computes the discount amount as follows:

if count < minimum then discount = 0;

if count >= minimum then discount = count * itemCost * percent

BuyNItemsGetOneFree implements the IDiscountPolicy interface. The constructor has one parameter: int n. n represents the numbers of items needed to get one item free. For example when n is 3, when buying 3 items one is free, when buying 6 items 2 are free. The

computeDiscount method computes the discount as follows:

discount = number of free items * itemCost

CombinedDiscount implements the IDiscountPolicy interface. The constructor has two parameters of type IDiscountPolicy. The computeDiscount method computes the discount amount using the two IDiscountPolicy objects and returns the largest discount amount.

The DiscountTester class tests the BulkDiscount, BuyNItemsGetOneFree and CombinedDiscount classes.

Assignment Guidelines:

1. Runyour programs with enough test cases to prove that the program works.Hand in the output for each test run.

2. For each source file include a comment that contains your name, assignment number and problem number.

3. Hand in a source code listing ( print out of your Java source

files) and the output produced by your program. Use Courier New

font.

4. Proper indentation.

5. Use Java Language Coding Guidelines (Appendix L) for variable

names, method names, class names and constant names.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

Students also viewed these Databases questions

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago