Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Debug The code works but is not meeting cengage requirements Screenshot: Details of whats wrong: DebugRowboat class: Test Output AssertionError: The `DebugRowboat` class contains

Java Debug

The code works but is not meeting cengage requirements

Screenshot:

image text in transcribed

Details of whats wrong:

DebugRowboat class:

Test Output

AssertionError: The `DebugRowboat` class contains a logic error. Double check the constructor to make sure it is setting the number of passengers.

Test Contents

import sys sys.tracebacklimit = 0 with open('/root/sandbox/DebugRowboat.java', 'r') as f: contents = "" for line in f.readlines(): contents += line assert "setPassengers();" in contents, "The `DebugRowboat` class contains a logic error. Double check the constructor to make sure it is setting the number of passengers." assert "setpower()" not in contents, "There is a naming convention issue with the `setPower()` method." assert "setPower()" in contents, "There is a naming convention issue with the `setPower()` method."

-----

debugEleven3

Custom TestIncomplete

Fix all logic and syntax errors in the DebugEleven3 class

Test Output

AssertionError: There is a logic error within the `if` statement

Test Contents

import re import sys sys.tracebacklimit = 0 with open('/root/sandbox/DebugEleven3.java', 'r') as f: contents = "" for line in f.readlines(): contents += line matches = re.findall("redBoat\s*\=\=\s*blueBoat", contents) assert "Main" not in contents, "There is a syntax issue with the `main` function." assert len(matches) == 1, "There is a logic error within the `if` statement"

Test CaseIncomplete

The program runs without issue and produces the expected output

Input

 

Output

The two boats are equal 

Results

The two boats are not equal

Expected Output

The two boats are not equal

-----------------------------------------------------------------------------------

code to copy:

public abstract class DebugBoat

{

String boatType = new String();

int passengers;

String power = new String();

public DebugBoat(String bt)

{

boatType = bt;

}

public boolean equals(DebugBoat otherBoat)

{

boolean result;

if((passengers == otherBoat.passengers) && (power.equals(otherBoat.power)))

result = true;

else

result = false;

return result;

}

public String toString()

{

return("This " + boatType + "boat carries " + passengers +

" and is powered by " + power);

}

public abstract void setPower();

public abstract void setPassengers();

}

----------------

// Two boats should be equal

// if they hold the same number of passengers

// and also have the same power source

class DebugEleven3

{

public static void main(String args[])

{

DebugRowboat redBoat = new DebugRowboat();

DebugRowboat blueBoat = new DebugRowboat();

System.out.print("The two boats are");

if(redBoat.equals(blueBoat))

System.out.println(" equal");

else

System.out.println(" not equal");

}

}

-----------------------

class DebugRowboat extends DebugBoat

{

public DebugRowboat()

{

super("row");

}

public void setPassengers()

{

super.passengers = 2;

}

public void setPower()

{

super.power = "oars";

}

}

Debugging Exercise 11-3 0 X Tasks Debug Boat.java DebugEleven3.java Debug Rowboat.java + _ Terminal + Fix all logic and syntax errors in the ... > sandbox $ rm -f * class sandbox $ sandbox $ sandbox $ javac DebugBoat.java DebugEleven3. java DebugRowboat.java sandbox $ java DebugEleven3 The two boats are equal sandbox $ 0 > Fix all logic and syntax errors in the Debug Rowboat class. > Fix all logic and syntax errors in the DebugEleven3 class. 1 public abstract class DebugBoat 2 { 3 String boatType = new String(); 4 int passengers; 5 String power = new String(); 6 public DebugBoat(String bt) 7{ 8 boat Type - bt; 9} 10 11 public boolean equals(DebugBoat otherBoat) 12 { 13 boolean result; 14 if((passengers == otherboat.passengers) && (power.equals(otherboat.power))) 15 result = true; 16 else 17 result = false; 18 return result; 19} 20 public String toString() 21 { 22 return("This " + boatType + "boat carries " + passengers + 23 and is powered by " + power); 24 ] 25 public abstract void setPower(); 26 public abstract void setPassengers(); 27] 28 ( Run Checks Submit 33% Debugging Exercise 11-3 0 X Tasks Debug Boat.java DebugEleven3.java Debug Rowboat.java + _ Terminal + Fix all logic and syntax errors in the ... > sandbox $ rm -f * class sandbox $ sandbox $ sandbox $ javac DebugBoat.java DebugEleven3. java DebugRowboat.java sandbox $ java DebugEleven3 The two boats are equal sandbox $ 0 > Fix all logic and syntax errors in the Debug Rowboat class. > Fix all logic and syntax errors in the DebugEleven3 class. 1 public abstract class DebugBoat 2 { 3 String boatType = new String(); 4 int passengers; 5 String power = new String(); 6 public DebugBoat(String bt) 7{ 8 boat Type - bt; 9} 10 11 public boolean equals(DebugBoat otherBoat) 12 { 13 boolean result; 14 if((passengers == otherboat.passengers) && (power.equals(otherboat.power))) 15 result = true; 16 else 17 result = false; 18 return result; 19} 20 public String toString() 21 { 22 return("This " + boatType + "boat carries " + passengers + 23 and is powered by " + power); 24 ] 25 public abstract void setPower(); 26 public abstract void setPassengers(); 27] 28 ( Run Checks Submit 33%

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_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

More Books

Students also viewed these Databases questions

Question

=+Are they specific or general in nature?

Answered: 1 week ago

Question

=+ What is the nature of the contracts or agreements with unions?

Answered: 1 week ago

Question

=+What is the procedure for labor relations in the workplace?

Answered: 1 week ago