Computer Science: Application Code FRQ
AP Java FRQ: Genres Galore Online Shop
Directions: SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN Java.
Notes:
· Assume that the classes listed in the Quick Reference have been imported where needed.
· Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied.
· In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods may not receive full credit.
Genres Galore, an online shop, sells themed items around the genres of science fiction, fantasy, and romance to eager fans. The shop has a close out sale at the end of every year. A genre theme is a specific movie, book, or online game within a genre. A trio package includes a t-shirt, bumper sticker, and magnet.
To take advantage of the end-of-year deals, customers need to buy a trio package which includes a t-shirt, bumper sticker, and magnet. The deals are calculated as follows:
· If a fan spends $30 or more on ANY combination of t-shirt, bumper sticker, and magnet, regardless of the theme, they receive 50% off their current purchase. Otherwise, there is no discount applied. They should receive the following message:
· If fans select a trio of themed items, they also receive a coupon for 50% off their next purchase. They should receive one of the following messages, depending on whether all 3 items have the same theme or not: "This is a themed trio. You get a coupon for 50% off your next order!" OR "This is not a themed trio. Would you like to keep shopping?"
Each item that the shop sells has a theme and price. The item types are represented by four classes: TShirt, BumperSticker, Magnet, and Trio. All four classes implement the GenresGalore interface as shown below.
GenresGalore
(interface)
BumperSticker
Magnet
TShirt
Trio
public interface GenresGalore
{
/** Returns the theme of each item */
String getTheme();
/** Returns the item price */
double getPrice();
}
Write the Trio class that implements the GenresGalore interface. Your implementation must include a constructor that takes three parameters representing a t-shirt, bumper sticker, and a magnet (in that order).
//initialize tShirt, bumperSticker, magnet (Note: These cannot be strings) GenresGalore trio = new Trio (tShirt, bumperSticker, magnet);
Write your solution here.