Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

//Chapter 9, Java Programming, Joyce Farrell, 8th; Debugged //error, need to to

ID: 3665923 • Letter: #

Question

//Chapter 9, Java Programming, Joyce Farrell, 8th; Debugged

//error, need to to fixed

1 // A Play has a title and author
2 // A Musical is a Play that also has a composer
3
4 public class DebugTen1
5 {
6 public static void main(String args[])
7 {
8 DebugPlay performance1 =
9 DebugPlay("Death of a Salesman", "Arthur Miller");
10 DebugMusical performance2 =
11 DebugMusical("Guys and Dolls", "Jo Swerling", "Frank Loesser");
12 performance1.display();
13 performance2.display();
14 }
15 }
16

/////

1 public class DebugBook
2 {
3 protected int pages;
4 public void DebugBook(int pgs)
5 {
6 pages = pgs;
7 }
8 public int getPages()
9 {
10 return pgs;
11 }
12 }

Explanation / Answer


class DebugTen1 {

   public static void main(String args[])
   {
       DebugPlay performance1 =new DebugPlay("Death of a Salesman", "Arthur Miller");
   DebugMusical performance2 = new DebugMusical("Guys and Dolls", "Jo Swerling", "Frank Loesser");
   performance1.display();
   performance2.display();
   }
}

class BebugBook{
     
   protected int pages;
   public void DebugBook(int pgs)
   {
   pages = pgs;
   }
   public int getPages()
   {
   return this.pages;
   }
}

// Play class
class DebugPlay{
   String name;
   String author;
   public DebugPlay(String name, String author) {
       super();
       this.name = name;
       this.author = author;
   }
   public void display(){
       System.out.println("Name: "+name+", and author: "+author);
   }
}

// Musical Class
class DebugMusical{
   String name;
   String author;
   String composer;
   public DebugMusical(String name, String author,String composer) {
       super();
       this.name = name;
       this.author = author;
       this.composer = composer;
   }
   public void display(){
       System.out.println("Name: "+name+", author: "+author+", and composer: "+composer);
   }
}

/*

OUTPUT:

Name: Death of a Salesman, and author: Arthur Miller
Name: Guys and Dolls, author: Jo Swerling, and composer: Frank Loesser

*/