Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

imageimage

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Answer below is the code package code public class Sandwich public static final double PRICEPEREXTRA ... 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_2

Step: 3

blur-text-image_3

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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions