Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

9.1.7 I'm not sure how to start. Please answer all parts using the given format. Thank you! For this activity, you are going to refactor

9.1.7 I'm not sure how to start. Please answer all parts using the given format. Thank you!
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
For this activity, you are going to refactor the Book superclass and the dictionary and Fiction subclasses. Right now, the Book class is empty and the Dictionary and Fiction classes have instance variables getter and setter methods. Your task is to move common attributes and methods to the Book supere and remove them from the subclasses. Note: You do not need a constructor in any class. 31 A MacBook Pro DOC boa F 17 % 2 3 4 5 6 7 be Tint FILES reec Dictava Book jave Fiction.java D BookTester java 1 public class BookTester 2-{ 3 public static void main(String[] args) 4 - { 5 Fiction hunger Games = new Fiction: 6 7 hunger Games.setPages(374); 8 hunger Games.setName("The Hunger Games"); 9 hunger Games.setAuthor("Suzanne Collins"): 10 11 Dict websters - new Dicto: 12 websters.setPages(720); 13 websters.setName("Webster's Dictionary"); 14 websters.setWords(171476); 15 16 System.out.printinChunger Games.getName(); 17 System.out.println(websters.getName(); 18 19] Sere 120-0 31 MacBook Pro NB $ 4 3 5 6 7. w F Status: Not Submitted 9.17: Books 07 Sun 2 iii 1 public class Fiction extends Book 2-1 Tint FILES private int pages; private String name; private String author: Dictvo Book.lv Fiction D BookTester.java public int getPages() { return pages; } ed 3 4 5 6 7- 8 9 10 11 - 12 13 14 15 - 16 17 18 public void setPages(int pages) { this.pages - pages: } public String getName() { return nome; } 19 Serd 320-0 public void setName(String name) { this.name = name; } 20 21 22 23 - 24 25 26 27 28 29 30 ] 31 public String getAuthor return outhor; } public void setAuthor(String author) this.author - author; } 31 MacBook Pro $ DE 70 2 3 4 5 6 7 Q W E R Status: Not Submitted 9.1.7: Books 1 public class Book III 2-1 an FILES 3 4 5 ] 6 Dictava Booklyn Fiction je D Booktustofa Sere 20-0 131 MacBook Pro 20 $ 2 3 4 5 6 7 W E R Y D Status: Not Submitted 9.1.7: Books Suami Cor lii FILES Det dan nec Back java D Fiction Java BookTester java 1 public class Dict extends Book 2.1 3 private int pages; 4 private String name; 5 private int words; 6 7. public int getPages 8 return pages: 9 } 10 public void setPages(int pages) { 12 this.pages - pages: 13 } 14 15 public String getNone 16 return name: 17 ] 18 public void setName(String name) { 20 this.name = name; 21 } 22 23 - public int getWords { 24 return words: 25 26 27 public void setWords(int words) { 28 this.words - words: 29 1 30 } 31 19. Send 20-0 31 MacBook Pro BE 23 S A 2 3 4. 5 6 7 Q W E R Y

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions