Question

In: Computer Science

4) A clothing store sells shoes, pants, and tops. The store also allows a customer to...

4) A clothing store sells shoes, pants, and tops. The store also allows a customer to buy an “outfit,” which consists of three items: one pair of shoes, one pair of pants, and one top. Each clothing item has a description and a price. The four type of clothing items are represented by the four classes Shoes, Pants, Top, and Outfit. All four classes implement the following ClothingItem interface.

public interface ClothingItem

{
   /** Return the description of the clothing item *//

   String getDescription();

   /** Return the price of the clothing item */

   double getPrice();

}

The following diagram shows the relationship between the ClothingItem interface and the Shoes, Pants, Top, and Outfit classes.

The store allows customers to create Outfit clothing items, each of which includes a pair of shoes, pants, and a top. The description of the outfit consists of the description of the shoes, pants, and top, in the order, separated by “/” and followed by a space and “outfit”. The price of an outfit is calculated as follows. If the sum of the prices of any two items equals or exceeds $100, there is a 25% discount on the sum of the prices of all three items. Otherwise, there is a 10% discount.

For example, an outfit consisting of sneakers ($40), blue jeans ($50), and a T-shit ($10), would have the name “sneakers/blue jeans/T-shirt outfit” and a price of 0.90(40 + 50 +10) = $90.00. An outfit consisting of loafers ($50), cutoffs ($20), and dress-shirt ($60), would have the description “loafers/cutoffs/dress-shirt outfit” and a price of 0.75(50 + 20 + 60) = $97.50

Write the Outfit class the implements the ClothingItem interface. Your implementation must include a constructor that takes three parameters representing a pair of shoes, pants, and a top, in that order.

A client class that uses the Outfit class should be able to create an outfit, and its description, and get its price. Your implementation should be such that the client code has the following behavior:

Shoes shoes;

Pants pants;

Top top;

/* Code to initialize shoes, pants, and top */

ClothingItem outfit =

   new Outfit(shoes, pants, top); //Compiles without error

ClothingItem outfit =

   new Outfit(pants, shoes, top); //Compile-time error

ClothingItem outdit =

   new Outfit(shoes, top, pants); //Compile-time error

Write your solution below.

Solutions

Expert Solution

Here is how the Outfit class will look, the question has reference to some diagram, which is not included in the question.

I have assumed class - Shoes, Pants and Top also implements the ClothingItem interface. Based on the assumption, here is how the code needs to be implemented.


================================================================================

public class Outfit implements ClothingItem{

    private Shoes shoes;
    private Pants pants;
    private Top top;

    public Outfit(Shoes shoes, Pants pants, Top top) {
        this.shoes = shoes;
        this.pants = pants;
        this.top = top;
    }

    @Override
    public String getDescription() {
        return shoes.getDescription()+"/"+
                pants.getDescription()+"/"+
                top.getDescription();
                ;
    }

    @Override
    public double getPrice() {
        return 
                shoes.getPrice() + pants.getPrice()+ top.getPrice();
                ;
    }
}


====================================================================


Related Solutions

A clothing store sells shoes, pants, and tops. The store also allows a customer to buy...
A clothing store sells shoes, pants, and tops. The store also allows a customer to buy an “outfit,” which consists of three items: one pair of shoes, one pair of pants, and one top. Each clothing item has a description and a price. The four type of clothing items are represented by the four classes Shoes, Pants, Top, and Outfit. All four classes implement the following ClothingItem interface. public interface ClothingItem {    /** Return the description of the clothing...
If a clothing store customer takes a pair of pants from the rack, removes all of...
If a clothing store customer takes a pair of pants from the rack, removes all of the external sales tags, and then approaches the sales clerk for a refund, what crime may be charged? Theft Criminal mischief Embezzlement None of the above
Smokey and the Bandit produces outdoor activity clothing. The product line consists of pants, jackets, tops,...
Smokey and the Bandit produces outdoor activity clothing. The product line consists of pants, jackets, tops, and accessories. Data has been collected related to direct materials and direct labor for the four product lines. Smokey and the Bandit has also collected information on four possible cost drivers (units, batches, machine hours, labor hours). All this information is listed below. Construct a spreadsheet that will allocate overhead for each of these alternative drivers and will calculate the total per unit cost...
Smokey and the Bandit produces outdoor activity clothing. The product line consists of pants, jackets, tops,...
Smokey and the Bandit produces outdoor activity clothing. The product line consists of pants, jackets, tops, and accessories. Data has been collected related to direct materials and direct labor for the four product lines. Smokey and the Bandit has also collected information on four possible cost drivers (units, batches, machine hours, labor hours). All this information is listed below. Construct a spreadsheet that will allocate overhead for each of these alternative drivers and will calculate the total per unit cost...
To better understand customer satisfaction with the service in the store a local clothing store decides...
To better understand customer satisfaction with the service in the store a local clothing store decides to conduct a survey. An employee of the store is asked to approach the first ten customers as they enter the store on three randomly selected Mondays in April, May, and June. The employee asks each customer, "How satisfied are you with the customer service in this store on a scale of 1-5 with 1 being not satisfied and 5 being very satisfied?" Identify...
A customer service manager at a retail clothing store has collected numerous customer complaints from the...
A customer service manager at a retail clothing store has collected numerous customer complaints from the forms they fill out on merchandise returns. To analyze trends or patterns in these returns, she has organized these complaints into a small number of sources or factors. en mensen e n de les emociona com a refer torse This is most closely related to the tool of TQM. A. scatter diagram B. histogram C. process control chart D. quality loss function E. cause-and-effect...
4. Payless Shoes has a shoe contract with a Hong Kong customer. Payless Shoes will pay...
4. Payless Shoes has a shoe contract with a Hong Kong customer. Payless Shoes will pay 30 million Hong Kong dollars (HK$) and is due in three months. The current spot and 3-month forward exchange rates are $0.13/HK$. a. Draw Payless’ expected future cash flow in Hong Kong dollars on a time line. b. Form a forward market hedge. c. Indicate how the hedge eliminates foreign exchange exposure by identifying the forward contract’s cash inflows and outflows on a time...
Ajax Company is a large retail company that sells clothing, shoes, and other apparel. It has...
Ajax Company is a large retail company that sells clothing, shoes, and other apparel. It has 40 retail outlets located in 22 states. All of the merchandise if purchased by a centralized procurement organization located at the company’s corporate headquarters. There are six purchasing agents with each agent assigned to purchase different types of goods. Each agent works independently with suppliers to get the best deals for the company. The six agents report to the purchasing director. The director oversees...
Midstate Industries is a retail clothing store. Marilyn Mounds knows that customer satisfaction is key to...
Midstate Industries is a retail clothing store. Marilyn Mounds knows that customer satisfaction is key to the success of her store. Indicate by placing an “X” in the appropriate column whether the following measures are leading or lagging and qualitative or quantitative. Each item may classify as more than one measure. 10 points Leading Lagging Qualitative Quantitative Attractive display of clothing items Dollars invested in display cases Overtime pay during sale days Quality of clothing Earnings per share Number of...
11. Running On Carla Gomez is the owner of Running On—a retail store that sells shoes...
11. Running On Carla Gomez is the owner of Running On—a retail store that sells shoes and accessories to runners. Carla is trying to decide what she should do with her retail business and how committed she should be to her current target market. Carla started Running On retail store in 1994 when she was only 24 years old. At that time, she was a nationally ranked runner and felt that the growing interest in jogging offered real potential for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT