Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. PLEASE PRINT THE OUTPUT 2. PLEASE IT ON ECLIPSE Pastry 1. Create a class named Pastry that has the instance attributes - description-string -

image text in transcribedimage text in transcribed1. PLEASE PRINT THE OUTPUT

2. PLEASE IT ON ECLIPSE

Pastry 1. Create a class named Pastry that has the instance attributes - description-string - price-double - isPremium-boolean 2. Pastry will contain a constructor with the single parameter of description. Within the constructor's code body, the price will be set to 95 cents and is Premi um will be false. 3. Pastry will also contain a 3 parameter constructor 4. Write getters and setters for all attributes. 5. Write the following custom methods: - boolean isFilled() : Examine the description of pastry. If the String "fill" (case-insensitive) is located anywhere in the description, return true. - boolean isDoubleFilled() : Examine the description of pastry. If the String "fill" (case-insensitive) is located anywhere at least two times in the description, return true. - String viewDescriptionIsAvailable (boolean isAvailable) : if the ingredient needed is available (the isAvailable parameter would equal true) return the description of pastry concatenated with the word " filled". Otherwise, just return the description of pastry. Sample data: - the description is "cinnamon bun" and the ingredient is NOT available-return the String "cinnamon bun" - the description is "doughnut, lemon curd" and isAvailable is true - return "doughnut, lemon curd filled" - the description is "napoleon with custard" and custard, the ingredient, is available, return "napoleon with custard filled" 6. Write a tostring that prints out the description, price and isPremium attributes, along with isFilled ( ) and isDoubleFilled () in an attractive and readable manner. Proper spacing and labeling should be included. A "table-like" structure will be enjoyed. PastryTester 1. PastryTester will contain a main method. Create 4 unique, meaningful pastry objects using the 3 parameter constructor. Create 2 unique, meaningful pastry objects using your 1 parameter constructor. 2. Create an array of pastries that contains all of your pastries named boxofPastries. 3. Using a looping structure print out the result of invoking the viewDescriptionIsAvailable method. This method requires a boolean parameter, please test for false and true for each object in your array. 4. Print out the contents of the array using one line of Java code. 5. Write a loop that totals the price of all of the pastries contained in boxofpastries (this would be the total price if each pastry was purchased separately). Print out this total based on each pastry to the console. Output/label this total as "Each pastry total: ". 6. Write a loop that discovers a "box-based" total. If there are at least three premium pastries in the box, the total is $20.19, otherwise the total of the box is $5.99. Print the "box-based" total to the console. Output/label this total as the "Box-based total: ". 7. To determine the price of the box of pastries, look at the total based on each pastry and the box-based total (the totals from 6 and 7). The lower of the two will be the price charged the customer. Print the lowest to the console as the "Purchase Price: ". a. For example, if the total based on each pastry is $4.25, and the box-based total is $5.99, you would output "Purchase Price: 4.25 ". b. If the total based on each pastry is $20.50 and the box-based total is $20.19, you would output "Purchase Price: 20.19

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

Multidimensional Array Data Management In Databases

Authors: Florin Rusu

1st Edition

1638281483, 978-1638281481

Students also viewed these Databases questions

Question

Identify and discuss the four kinds of quality costs.

Answered: 1 week ago