The code for the Book class

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; } public String toString() { return super.toString() + "Author: " + author + "\n"; } }

The code for Software class

public class software extends Product { private String version; public Software() { super(); // call constructor of Product superclass version = ""; count++; // update the count variable in the Product superclass } public void setVersion(String version) { this.version = version; } public String getVersion() { return version; } public String toString() // override the toString method { return super.toString() + "Vesion: " + version + "\n"; } }
Site hosted by Angelfire.com: Build your free website today!