Question: /Debugged, Joyce Farrell, Java Programming, Chapter 10 // need to be fixed, there is error when u run the java. //there are 2 class below
/Debugged, Joyce Farrell, Java Programming, Chapter 10
// need to be fixed, there is error when u run the java.
//there are 2 class below
1 // A PhoneBook is a Book with a city 2 import javax.swing.*; 3 public class DebugTen3 4 { 5 public static void main(String[] args) 6 { 7 String area, inStr; 8 int pages; 9 area = JOptionPane.showInputDialog(null, 10 "Enter city for phone book"); 11 inStr = JOptionPane.showInputDialog(null, 12 "Enter number of pages in " + area + "'s phone book"); 13 pages = Integer.parseInt(inStr); 14 DebugPhoneBook pb = new DebugPhoneBook(); 15 pb.display(); 16 } 17 }
-------------------------------------------------------------
// class for DebugTen3
1 import javax.swing.*; 2 public class DebugPhoneBook extends DebugBook 3 { 4 private String area 5 private String size 6 private final int CUTOFF = 30; 7 FixDebugPhoneBook(int pages, int city) 8 { 9 super(pages); 10 area = city; 11 if(pages < CUTOFF) 12 size = "big"; 13 else 14 size = "small"; 15 } 16 public void display() 17 { 18 JOptionPane.showMessageDialog(null,"The phone book for " + area + 19 " has " + pages + " pages. That is a " + 20 size + " phone book."); 21 } 22 }
----------------------------------------------------------
//class for DebugTen3
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 }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
