Question
//Debug 1 Chapter 11 //Java Programming, joyce farrell, 8th //output //need to fix it is error when running //show the right code 1 // Instantiates
//Debug 1 Chapter 11
//Java Programming, joyce farrell, 8th
//output //need to fix it is error when running
//show the right code
1 // Instantiates Rowboat 2 // Rowboat is child of Boat 3 public class DebugEleven1 4 { 5 public static void main(String[] args) 6 { 7 DebugRowboat myBoat = new Rowboat(); 8 System.out.println(myBoat.toString()); 9 } 10 } 11
===============
1 public class DebugRowboat extends DebugBoat 2 { 3 public DebugRowboat() 4 { 5 super("row"); 6 } 7 public void setPassengers() 8 { 9 super.passengers = 2; 10 } 11 public void setPower() 12 { 13 super.power = "oars"; 14 } 15 }
=============
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 // override equals() method to satisfy 11 // requirements of Debug Exercise 3. 12 public boolean equals(DebugBoat otherBoat) 13 { 14 boolean result; 15 if((passengers == otherBoat.passengers) && (power.equals(otherBoat.power))) 16 result = true; 17 else 18 result = false; 19 return result; 20 } 21 public String toString() 22 { 23 return("This " + boatType + "boat carries " + passengers + 24 " and is powered by " + power); 25 } 26 public abstract void setPower(); 27 public abstract void setPassengers(); 28 }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started