Using the provided code (Question01.java and Question02.java), create a class Sandwich that has the following. Requirements:...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Using the provided code (Question01.java and Question02.java), create a class Sandwich that has the following. Requirements: • Functionality. (20pts) o No Syntax, Major Run-Time, or Major Logic Errors. (20pts*) ■ *Code that cannot be compiled due to syntax errors is nonfunctional code and will receive no points for this entire section. ■ *Code that cannot be executed or tested due to major run-time or logic errors is nonfunctional code and will receive no points for this entire section. ■ *In addition, the solution must work with the unmodified version of the provided code. o Properties / Instance Variables and Constants (5pts) ■ Name: this is the name of the sandwich. This value should not be null, and its default value is "none". ■ Base Price: This is the base price of the sandwich without adding the extra ingredients. It should be a non-negative, decimal value and its default value should be 1.0. ■ Extras: this is a non-negative whole number value that represents the extra ingredients added to the sandwich. Its default value should be 0. ■ Price Per Extra: This constant decimal value is the cost of each extra ingredient and should be set to 0.99. ■ Instance variables and constants must follow the same rules regarding their scope and identifiers. ■ All must apply for full credit. o Constructors (5pts) ▪ Default: set the instance variables to a default value as described in the "Properties / Instance Variables and Constants" section. ■ Parameterized: One that takes in three parameters that will set the instance variables and check for valid values. The order of these parameters needs to follow the order found in part the "Properties / Instance Variables and Constants” section. (IE the first point's variable must occur first, then second point's variable must occur next, and so on). ■ All must apply for full credit. o Accessors and Mutators for Each Instance Variable (10pts) ■ Accessors and Mutators must follow the same structure that is used in lecture including but not limited to the scope, return types, identifiers, and parameters. (5pts) ■ Mutators must check for valid values as described in the "Properties / Instance Variables and Constants" section, and if the provided value is invalid the method must set the property to its default value. (5pts) ■ All must apply for full credit. • Coding Style. (2pts) o Readable Code ■ Meaningful identifiers for data and methods. ■ Proper indentation that clearly identifies statements within the body of a class, a method, a branching statement, a loop statement, etc. ■ All the above must apply for full credit. • Comments. (3pts) o Your name in the file. (1pts) Question01 Tests The class constant is: 0.99 Constructing a new instance of Sandwich using the Default Constructor Testing Accessors Name: none Base Price: 1.0 Extras: 0 Testing Mutators with Correct Values Testing Accessors Name: ASDF Base Price: 4.99 Extras: 2 Testing Mutators with Incorrect Values Name: none Base Price: 1.0 Extras: 0 Constructing a new instance of Sandwich using the Param Constructor Name: ASDF2 Base Price: 7.99 Extras: 4 Using the provided code (Question01.java and Question02.java), create a class Sandwich that has the following. Requirements: • Functionality. (20pts) o No Syntax, Major Run-Time, or Major Logic Errors. (20pts*) ■ *Code that cannot be compiled due to syntax errors is nonfunctional code and will receive no points for this entire section. ■ *Code that cannot be executed or tested due to major run-time or logic errors is nonfunctional code and will receive no points for this entire section. ■ *In addition, the solution must work with the unmodified version of the provided code. o Properties / Instance Variables and Constants (5pts) ■ Name: this is the name of the sandwich. This value should not be null, and its default value is "none". ■ Base Price: This is the base price of the sandwich without adding the extra ingredients. It should be a non-negative, decimal value and its default value should be 1.0. ■ Extras: this is a non-negative whole number value that represents the extra ingredients added to the sandwich. Its default value should be 0. ■ Price Per Extra: This constant decimal value is the cost of each extra ingredient and should be set to 0.99. ■ Instance variables and constants must follow the same rules regarding their scope and identifiers. ■ All must apply for full credit. o Constructors (5pts) ▪ Default: set the instance variables to a default value as described in the "Properties / Instance Variables and Constants" section. ■ Parameterized: One that takes in three parameters that will set the instance variables and check for valid values. The order of these parameters needs to follow the order found in part the "Properties / Instance Variables and Constants” section. (IE the first point's variable must occur first, then second point's variable must occur next, and so on). ■ All must apply for full credit. o Accessors and Mutators for Each Instance Variable (10pts) ■ Accessors and Mutators must follow the same structure that is used in lecture including but not limited to the scope, return types, identifiers, and parameters. (5pts) ■ Mutators must check for valid values as described in the "Properties / Instance Variables and Constants" section, and if the provided value is invalid the method must set the property to its default value. (5pts) ■ All must apply for full credit. • Coding Style. (2pts) o Readable Code ■ Meaningful identifiers for data and methods. ■ Proper indentation that clearly identifies statements within the body of a class, a method, a branching statement, a loop statement, etc. ■ All the above must apply for full credit. • Comments. (3pts) o Your name in the file. (1pts) Question01 Tests The class constant is: 0.99 Constructing a new instance of Sandwich using the Default Constructor Testing Accessors Name: none Base Price: 1.0 Extras: 0 Testing Mutators with Correct Values Testing Accessors Name: ASDF Base Price: 4.99 Extras: 2 Testing Mutators with Incorrect Values Name: none Base Price: 1.0 Extras: 0 Constructing a new instance of Sandwich using the Param Constructor Name: ASDF2 Base Price: 7.99 Extras: 4
Expert Answer:
Answer rating: 100% (QA)
Answer below is the code package code public class Sandwich public static final double PRICEPEREXTRA ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Troy Engines, Ltd., manufactures a variety of engines for use in heavy equipment. The company has always produced all of the necessary parts for its engines, including all of the carburetors. An...
-
Choke Cherry Ltd. is a private company reporting under ASPE. Its adjusted trial balance at its fiscal year end, December 31, 2017, is shown below: Instructions Prepare an income statement, statement...
-
For a long-term high-yield coupon bond, do you think that the total return from holding a bond to maturity will be closer to the yield to maturity or the reinvestment rate?
-
What is the speed of a proton after being accelerated from \(\mathbb{N} T\) rest through a \(50 \times 10^{6} \mathrm{~V}\) potential difference?
-
Bao Company lost all of its inventory in a fire on December 26, 2017. The accounting records showed the following gross profit data for November and December. Bao is fully insured for fire losses but...
-
Develop a pricing strategy that balances profitability and competitiveness. Suggest promotional activities and campaigns to attract and retain customers.
-
3. You are given a high modulus carbon fiber (Ef = 4100 GPa, vf = 0.18) and epoxy (Em 3.5 GPa, Vm = 0.4) to make into a unidirectional long fiber composite. Assume that the fibers and matrix are...
-
Identify the three primary areas a project manager must focus on to ensure success. Explain which area you feel is most important and why.
-
what are the situational examples of the article 1796 of the philippines which states that the partnership shall be responsible to every partner for the amounts he may have disbursed on behalf of the...
-
Explore the four issues identified in the Key Problems section. At least one paragraph per issue. Why is the problem a key issue for Trivago? Why is the problem impacting Trivago's strategic success.
-
What's the importance of a Documentation Plan? Please provide an example of a Documentation Plan that you would use. How do you calculate how long a project will take?
-
can be employed to evaluate the performance of business units within a company. Units with returns exceeding their respective WACC are likely contributing positively to the company's value, while...
-
Let y = e5z + sin(x2). Then equals (a) 5eb + cos(x) (e) none of these (b) ebr +2x cos(x2) (c) ebz + cos(r) (d) 5e + 2x cos(r2)
-
(a) Find the equation of the tangent line to f(x) = x 3 at the point where x = 2. (b) Graph the tangent line and the function on the same axes. If the tangent line is used to estimate values of the...
-
Ken paid the following amounts for interest during 2012: Qualified interest on home mortgage...........................................$4,700 Auto loan...
-
In 2012, Gale and Cathy Alexander hosted an exchange student, Axel Muller, for 9 months. Axel was part of International Student Exchange Programs (a qualified organization). Axel attended tenth grade...
-
Deborah purchases a new $30,000 car in 2012 to use exclusively in her business. If Deborah does not elect to expense or take bonus depreciation in 2012 and holds the car until it is fully...
-
Which of the following is a discrete probability distribution? Approach In a discrete probability distribution, the sum of the probabilities must equal 1, and all probabilities must be between 0 and...
-
Graph the discrete probability distribution given in Table 1 from Example 2. Approach In the graph of a discrete probability distribution, the horizontal axis represents the values of the discrete...
-
Compute the mean of the discrete random variable given in Table 1 from Example 2. Approach Find the mean of a discrete random variable by multiplying each value of the random variable by its...
Study smarter with the SolutionInn App