Java: An Introduction to Problem Solving and Programming (7th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 6, Problem 4PP

Complete and fully test the class Characteristic that Exercise 5 describes. Include the following methods:

  • getDescription—returns the description of this characteristic.
  • getRating—returns the rating of this characteristic.
  • getCompatability (Characteristic otherRating)—returns the compatibility measure of two matching characteristics, or zero if the descriptions do not match.
  • getCompatabilityMeasure (Characteristic otherRating)— private method that returns a compatibility measure as a formula double value using the formula

    [ m = 1 ( r 1 r 2 ) 2 81 ]

    when both ratings are nonzero; m is zero if either rating is zero. (Recall from Exercise 5 that the constructor sets the rating to zero, indicating that it has not yet been determined.)

  • isMatch(Characteristic otherRating)— a private method that returns true if the descriptions match.
Blurred answer
Students have asked these similar questions
Create a RightTriangle class given the following design: RightTriangle variables: base, height methods: 2 constructors, 1 that set default values and another that accepts to parameters. setBase - changes the base. Requires one parameter for base. setHeight - changes the height. Requires one parameter for height. getBase - returns the triangle base. getHeight - returns the triangle height. area - returns the area of the triangle (1/2bh) given the current base and height
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…
Slide Type Slide • Exercise # 1: Define a class Point that represents a point in 2 – D plane. The point has x and y coordinates. Define the following: • A constructor to initialize the x, y coordinates. • A method translate(self, dx,dy) to translate the point object dx , and dy units in x and y directions, respectively. • A method distanceTo (self, point2) to return the distance between the point referenced by self and point2. • getX(self) to return the value of x coordinate. • getY(self) to return the value of y coordinate Test the above class by: • Creating 2 point objects; one with (3,5) as x,y coordinates; the second with (-10,30) as x,y coordinates. • Move the first point 5.5 units in x direction and -12.5 units in y direction using translate method • Find the distance between the 2 points in their current location using distance To method A Sample output resulting from running the above test class is shown below new coordinates of point1= (8.5 , -7.5) Coordinates of point 2 =…

Chapter 6 Solutions

Java: An Introduction to Problem Solving and Programming (7th Edition)

Ch. 6.2 - Can you reference an instance variable by name...Ch. 6.2 - Is the following valid, given the class...Ch. 6.2 - Prob. 13STQCh. 6.2 - Prob. 14STQCh. 6.2 - Prob. 15STQCh. 6.2 - Is the following valid, given the class...Ch. 6.2 - What values are returned by each of the following?...Ch. 6.2 - Suppose that speed is a variable of type double...Ch. 6.2 - Repeat the previous question, but instead assign...Ch. 6.2 - Suppose that nl is of type int and n2 is of type...Ch. 6.2 - Define a class CircleCalculator that hat only two...Ch. 6.2 - Which of the following statements are legal?...Ch. 6.2 - Write a Java expression to convert the number in...Ch. 6.2 - Consider the variable 5 of type String that...Ch. 6.2 - Repeat the previous question, but accommodate a...Ch. 6.2 - Write Java code to display the largest and...Ch. 6.3 - Prob. 27STQCh. 6.3 - Consider the variable allCents in the method...Ch. 6.3 - What is wrong with a program that starts as...Ch. 6.3 - Prob. 30STQCh. 6.3 - In your definition of the class OutputFormat. In...Ch. 6.4 - Prob. 32STQCh. 6.4 - Prob. 33STQCh. 6.4 - Prob. 34STQCh. 6.4 - Consider the class Species in Listing 5.19 of...Ch. 6.4 - Repeat the previous question for a method...Ch. 6.4 - Still considering the class Species in Listing...Ch. 6.4 - Rewrite the method add in Listing 6.16 so that it...Ch. 6.4 - In Listing 6.16, the set method that has a String...Ch. 6.5 - Give the definitions of three accessor methods...Ch. 6.6 - If cardSuit is an instance of Suit and is assigned...Ch. 6.7 - Suppose you want to use classes in the package...Ch. 6.7 - Prob. 43STQCh. 6.7 - Can a package have any name you might want, or are...Ch. 6.7 - On your system, place the class Pet (Listing 6.1)...Ch. 6.8 - Prob. 46STQCh. 6.8 - Prob. 47STQCh. 6.8 - Prob. 48STQCh. 6.8 - Prob. 49STQCh. 6.8 - Prob. 50STQCh. 6.8 - Prob. 51STQCh. 6.8 - Revise the applet in Listing 6.24 so that the...Ch. 6 - Prob. 1ECh. 6 - Prob. 2ECh. 6 - Write a default constructor and a second...Ch. 6 - Write a constructor for the class...Ch. 6 - Consider a class characteristic that will be used...Ch. 6 - Create a class RoomOccupancy that can be used to...Ch. 6 - Write a program that tests the class RoomOccupancy...Ch. 6 - Sometimes we would like a class that has just a...Ch. 6 - Create a program that tests the class Merlin...Ch. 6 - In the previous chapter, Self-Test Question 16...Ch. 6 - Create a class Android whose objects have unique...Ch. 6 - Prob. 12ECh. 6 - Modify the definition of the class Species in...Ch. 6 - Prob. 2PCh. 6 - Using the class Pet from Listing 6.1, write a...Ch. 6 - Do Practice Program 4 from Chapter 5 except define...Ch. 6 - The following class displays a disclaimer every...Ch. 6 - Do Practice Program 5 from Chapter 5 but add a...Ch. 6 - We can improve the Beer class from the previous...Ch. 6 - Define a utility class for displaying values of...Ch. 6 - Write a new class TruncatedDollarFormat that is...Ch. 6 - Complete and fully test the class Time that...Ch. 6 - Complete and fully test the class Characteristic...Ch. 6 - Write a Java enumeration LetterGrade that...Ch. 6 - Complete and fully test the class Per n that...Ch. 6 - Write a Temperature class that represents...Ch. 6 - Repeat Programming Project 8 of the previous...Ch. 6 - Write and fully test a class that represents...Ch. 6 - Write a program that will record the votes for one...Ch. 6 - Repeat Programming Project 10 from Chapter 5, but...Ch. 6 - Prob. 12PPCh. 6 - Prob. 13PPCh. 6 - Prob. 14PPCh. 6 - Prob. 15PP
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Memory Management Tutorial in Java | Java Stack vs Heap | Java Training | Edureka; Author: edureka!;https://www.youtube.com/watch?v=fM8yj93X80s;License: Standard YouTube License, CC-BY