Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
6th Edition
ISBN: 9780134477367
Author: David J. Barnes, Michael Kolling
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 9, Problem 6E
Good boundary testing also involves testing values that lie just beyond the valid range of data. Test 0 and 6 as rating values. In both cases, the comment should be rejected (addComment should return false, and the comment should not be added to the comment list.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Create functional tests where arguments are given, use a parameterized test.
testSimpleInit(size): the first constructor works as expected.
getTiles shows suitable values.
The edges of the board (the smallest and biggest conceivable values) are accessible and contain the values that they have to (BASE_TILE_SCORE).
testCustomInit(x, y, expected): the second constructor works as expected.
On positions where values smaller than three were passed, the board contains the value BASE_TILE_SCORE.
If you pass an array to the constructor and later modify a value in it, the respective tile retains the originally passed value.
If you modify an element in the return value of getTiles(), and get the value of the respective tile again, this newly received content has to be the originally set value.
testMoves(): take four or five steps and check that the board’s contents are changed just right.
Include a step that tries to move to the x coordinate Integer.MIN_VALUE and another one that moves to…
use this code template to help you continue:
private boolean included
Indicates whether the item should be taken or not
public Item(String name, double weight, int value)
Initializes the Item’s fields to the values that are passed in; the included Field is initialized to false
public Item(Item other)
Initializes this item’s fields to the be the same as the other item’s
public void setIncluded(boolean included)
Setter for the item’s included field (you don’t need setters for the other fields)
Given code:
public class Item {
private final String name;
private final double weight;
private final int value;
public Item(String name, double weight, int value) {
this.name = name;
this.weight = weight;
this.value = value;
}
static int max(int a, int b)
{
if(a > b)
return a;
return b;
}
// function to print the items which are taken
static void printSelection(int W, Item[] items, int…
The final keyword should be used on any instance field, parameter, or local variable that will not or should not change after initialization. This protects against inadvertently changing the value elsewhere in the code.
True/False
Chapter 9 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write the method header for the ShowRetailPrice method. A list price and a markup % should be parameter variables in the procedure. Create a method with a default markup percentage of 50% as the default parameter.arrow_forwardProgram Specifications Write a FancyCar class to support basic operations such as drive, add gas, honk horn and start engine. fancy_car.py is provided with function stubs. Follow each step to gradually complete all instance methods. Note: This program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. The main program includes basic calls to the instance methods. Add statements in the main program as instance methods are completed to support development mode testing. **Step 0: Complete the constructor to initialize the model and miles per gallon (MPG) with the values of the parameters. Initialize the odometer to five miles and the tank to be full of gas. By default, the model is initialized to "Old Clunker", and MPG is initialized to 24.0. Note the provided constant variable indicates the gas tank capacity of 14.0 gallons. Step 1 Complete the instance…arrow_forwardThe code given below represents a saveTransaction() method which is used to save data to a database from the Java program. Given the classes in the image as well as an image of the screen which will call the function, modify the given code so that it loops through the items again, this time as it loops through you are to insert the data into the salesdetails table, note that the SalesNumber from the AUTO-INCREMENT field from above is to be inserted here with each record being placed into the salesdetails table. Finally, as you loop through the items the product table must be update because as products are sold the onhand field in the products table must be updated. When multiple tables are to be updated with related data, you should wrap it into a DMBS transaction. The schema for the database is also depicted. public class PosDAO { private Connection connection; public PosDAO(Connection connection) { this.connection = connection; } public void…arrow_forward
- Rules: Corner cases. By convention, the row and column indices are integers between 0 and n − 1, where (0, 0) is the upper-left site. Throw an IllegalArgumentException if any argument to open(), isOpen(), or isFull() is outside its prescribed range. Throw an IllegalArgumentException in the constructor if n ≤ 0. Unit testing. Your main() method must call each public constructor and method directly and help verify that they work as prescribed (e.g., by printing results to standard output). Performance requirements. The constructor must take Θ(n^2) time; all instance methods must take Θ(1)Θ(1) time plus Θ(1)Θ(1) calls to union() and find().arrow_forwardModified Circle class and test file: Add a new attribute for color (or any other new attribute) Add get/set methods for this new instance variable, including data validation in set method (assuming background is black, i.e. circle color can't be black, reset to any non-black color if black is entered ). Add a new constructor to pass the color attribute as an argument. Add an instance method to display all properties of a Circle object. Create 2 objects using different constructors in test file, with invalid data. Use this test java file test java file: class CircleTest{ public static void main(String[] args){ int num = 10; Circle c1 = new Circle(0.001); Circle c2 = new Circle("black", -9); c1.display(); c2.display(); c1.setRadius( -1); c1.setColor("black"); c1.display(); }}arrow_forwardUse this code template to continue the code: public Item(String name, double weight, int value) Initializes the Item’s =ields to the values that are passed in; the included =ield is initialized to false public Item(Item other) Initializes this item’s fields to the be the same as the other item’s public double getWeight() public int getValue() public boolean isIncluded() Getter for the item’s fields (you don’t need a getter for the name) Given code: public class Item { private final String name; private final double weight; private final int value; private boolean included; public Item(String name, double weight, int value) { this.name = name; this.weight = weight; this.value = value; } public Item(Item item){ name = item.name; weight = item.weight; value = item.value; } public void…arrow_forward
- in Jave create two methods work(), and interwork() with the follow instructions: You may assume that the work() method is passed a List that does not contain any null elements. (Note: The List may contain missing elements.) The work() method must not have any side effects. That is, it must not change the parameters that it is passed in any way and it must not change any attributes in any way. The work() method must return the weighted average of the elements in the List it is passed. The label of the result must equal the parameter named rl. The data parameter contains the values to use in the calculation. If an element of data is missing (i.e., has a value attribute that is null) then that element must be ignored in the calculation. The weights attribute contains the weights to use in the calculation. If the weights attribute is null then all weights used in the calculation must be 1. You may assume that all of the elements of weights (if it is non-null) are…arrow_forwardTrue or False: When numerous parameters are supplied to a method, the order in which they are passed is irrelevant.arrow_forwardin Jave create two methods work(), and interwork() with the follow instructions: You may assume that the work() method is passed a List that does not contain any null elements. (Note: The List may contain missing elements.) The work() method must not have any side effects. That is, it must not change the parameters that it is passed in any way and it must not change any attributes in any way. The work() method must return the weighted average of the elements in the List it is passed. The label of the result must equal the parameter named rl. The data parameter contains the values to use in the calculation. If an element of data is missing (i.e., has a value attribute that is null) then that element must be ignored in the calculation. The weights attribute contains the weights to use in the calculation. If the weights attribute is null then all weights used in the calculation must be 1. You may assume that all of the elements of weights (if it is non-null) are…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Structured Chart; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=vdUO-sGA1DA;License: Standard YouTube License, CC-BY
Introduction to Structure Charts; Author: Christopher Kalodikis;https://www.youtube.com/watch?v=QN2bjNplGlQ;License: Standard Youtube License