Answered step by step
Verified Expert Solution
Question
1 Approved Answer
AP CS Test 6: Inheritance suas ns al 20W (1 1) [18pt] This question involves the using of an interface. A trendy millennial-owned clothing
AP CS Test 6: Inheritance suas ns al 20W (1 1) [18pt] This question involves the using of an interface. A trendy millennial-owned clothing store downtown sells coats, pants, and shirts. The store also allows a customer to buy a "pair," which consists of two of the three items. Each clothing item has a description and a price. The four types of clothing items are represented by the four classes: Coat, Pants, Shirt, and Pair. All four classes extend the following ClothingItem abstract class: public abstract class ClothingItem /** @return the description of the clothing item */ public abstract String getName(); /** @return the price of the clothing item */ public abstract double getPrice (); following The following diagram shows the relationship between the ClothingItem parent class and the Coat, Pants, Shirt, and Pair classes. 71 Jeum casie oda Bru to abbsid. 16 neowded Coat Deat pods suni TOM al eniwollat eri to ClothingItem < > Pants on even n60 A erle aswil sidshverl of beinsw uoy 11 (A sdw ,22sb Shirt Pair bow Iani) (A The store allows customers to create a Pair of clothing items which include two of the following: Coat, Pants, or Shirt. The items in the Pair may be different or they might be the same, for example a Pair could be two Coats, or Pants and a Shirt. The Pair's description consists of the first item's name and the second item's name, separated by the word "and" and followed by the word "combo", inserting spaces when appropriate. The price of the Pair is calculated by adding the two items together, and if their value is greater than or equal to $50, the price is reduced by 20%. [That means an order of $49.99 is basically a waste of money, because 1 more cent would have triggered the discount, bringing the price to $40. Rofl Capitalism.] For example, a Pair consisting of a Coat "Blazer" ($60) and a Shirt "Flaming Skull T-Shirt" ($20) would have the description "Blazer and Flaming Skull T-Shirt combo" and a price of $64 (60 + 20 is 80, which is over 50, so there is a 20% discount). A different Pair consisting of Shirt "Hipster Graphic Tee" ($15) and Pants "Uncomfortably Tight Jeans" ($20) would have the description "Hipster Graphic Tee and Uncomfortably Tight Jeans combo" and a price of $35 (which did not receive the discount). [Hint: Remember how to do discount with percentages...] Write the Pair class that extends the ClothingItem class. Your implementation must include a constructor that takes two parameters, which are of type ClothingItem, and any other required methods and/or instance variables. The constructor will be always passed two existing objects.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
the Pair class that extends the ClothingItem classThe class should have a constructor that takes two parameterswhich are of type ClothingItemand any other required methods andor instance variablesThe ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started