Answered You can hire a professional tutor to get the answer.

QUESTION

public class Book extends Product { private String author; public Book() { super(); author = ; count++; } public void setAuthor(String...

Intro to Java Exercise: -I attached the project as a zip file and also included multiple .java files for convenience.-I also attached a word document for easier reading.Exercise 8-3 Use the abstract and final keywords-In this exercise, you'll change the Product class in the Product application to an abstract class to see how that works, and you'll add an abstract method and implement it in the Book, Software, and CompactDisc subclasses. Then, you'll change the Book class to a final class to see that a final class can't be inherited, and you'll create a final method to see that it can't be overridden.CHANGE THE PRODUCT CLASS TO AN ABSTRACT CLASS 1. Open the project named ch08_ex3_Product. Then, review the code.2. Add the abstract keyword to the Product class declaration. 3. Open the ProductApp class, and add this statement before the statement that calls the getProduct method:Product pTest = new Product();4. If you're using NetBeans, a syntax error should be displayed indicating that the Product class is declared as abstract and cannot be instantiated. If this error isn't displayed, save or compile the ProductApp class so it is displayed. 5. Delete the statement you just added. Then, run the application to make sure it works.ADD AN ABSTRACT METHOD TO THE PRODUCT CLASS6. Add an abstract method named getDisplayText to the Product class. This method should accept no parameters, and it should return a String object. Then, compile this class.7. Rename the toString methods in the Book and Software classes to getDisplayText. 8. Modify the ProductApp class so it calls the getDisplayText method of a product instead of the toString method. Then, run the application to be sure it works correctly.CHANGE THE BOOK CLASS TO A FINAL CLASS9. Add the final keyword to the Book class declaration.10. Create a class named UsedBook that inherits the Book class. You don't need to include any code in the body of this class. If you're using NetBeans, a syntax error should be displayed indicating that the Book class can't be inherited because that class is final. If this error isn't displayed, save or compile the Book and UsedBook classes so it is displayed.ADD A FINAL METHOD 11. Remove the final keyword from the Book class declaration. Then, add the final keyword to the getDisplayText method of the Book class.12. Add a getDisplayText method to the UsedBook class to ovenide the getDisplayText method of the Book class. Code this method so it returns an empty string. If you're using NetBeans, a syntax error should be displayed indicating that the getDisplayText method can't be overridden because that method is final. If this message isn't displayed, save or compile the Book and UsedBook classes so it is displayed.13. Remove the final keyword from the getDisplayText method of the Book class. Now, no syntax errors should be displayed. If you get a warning about the @Override annotation, though, add this annotation to the getDisplayText method of the UsedBook class.

  • Attachment 1
  • Attachment 2
  • Attachment 3
  • Attachment 4
  • Attachment 5
  • Attachment 6
public class Book extends Product{private String author;public Book(){super();author = "";count++;}public void setAuthor(String author){this.author = author;}public String getAuthor(){return author;}@Overridepublic String toString(){return super.toString() +"Author:" + author + "\n";}}
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question