Question: Java debug code to copy public abstract class DebugBoat { String boatType = new String(); int passengers; String power = new String(); public DebugBoat(String bt)
Java debug
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();
}
----
// Creates and displays an array of boats -
// some are rowboats; some are ocean liners
import java.util.*;
public class DebugEleven4
{
static Scanner input = new Scanner(System.in);
static DebugBoat[] boatArray = new DebugBoat[5];
public static void main(String[] args)
{
buildArray();
displayArray();
}
public static void buildArray()
{
char boatType;
for(int x = 0; x
{
boatType = getBoat();
if(boatType =='r')
boatArray[x] = DebugRowboat();
else
boatArray[x] = new DebugOceanLiner();
}
}
public static char getBoat()
{
String boatType;
System.out.println("Enter r for rowboat; o for ocean liner ");
boatType = input.next();
return boatType.charAt(0);
}
public static void displayArray()
{
for(int x = 0; x
System.out.println("Boat #" + (x + 1) + " " +
boatArray[x].toString());
}
}
---
public class DebugOceanLiner extends DebugBoat
{
public DebugOceanLiner()
{
super("ocean liner ");
setPassengers();
setPower();
}
public void setPassengers()
{
super.passengers = 2400;
}
public void setPower()
{
super.power = "four engines";
}
}
---
public class DebugRowboat extends DebugBoat
{
public DebugRowboat()
{
super("row");
setPower();
setPassengers();
}
public void setPassengers()
{
super.passengers = 2;
}
public void setPower()
{
super.power = "oars";
}
}
Debugging Exercise 11-4 Tasks Debug Boat.java DebugEleven4.java DebugOceanLine... Debug Rowboat.ja... + + >_ Terminal Fix all logic and syntax errors in the DebugBoat class. sandbox $ rm -f * class sandbox $ sandbox $ sandbox $ javac DebugBoat.java DebugEleven4. java DebugOceanliner.java DebugRowboat.java DebugEleven4.java:21: error: cannot find sym bol boatArray[x] = DebugRowboat(); Fix all logic and syntax errors in the ... > Fix all logic and syntax errors in the ... > Fix all logic and syntax errors in the DebugEleven4 class. symbol: method DebugRowboat() location: class DebugEleven4 1 error sandbox $ java DebugEleven4 Error: Could not find or load main class Deb ugEleven4 sandbox $ | 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 boatType = bt; 9 } 10 public boolean equals(DebugBoat otherBoat) 11 12 boolean result; 13 if((passengers == otherboat.passengers) && (power.equals (otherBoat.power))) 14 result = true; 15 else 16 result = false; 17 return result; 18 19 public String toString() 20 { 21 return("This " + boatType + "boat carries + passengers + 22 and is powered by" + power); 23 } 24 public abstract void setPower(); 25 public abstract void setPassengers(); 26 ) 27 Run Checks Submit 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
