Question: I have two subclasses implemented below in Java; User and Document and their superclass Wiki however I keep getting an error saying that Wiki must
I have two subclasses implemented below in Java; User and Document and their superclass Wiki however I keep getting an error saying that Wiki must have a default constructor. I don't know how to fix this because I want Wiki to have a constructor that accepts a string as its title just like the subclasses. Help me fix this and feel free to edit the classes to show good OO properties and use Javas built in LinkedList as for your list variable. The only difference between both subclasses is their print method.
public abstract class Wiki { private String title; private List content; public Wiki(String title){ if (title.length()<80) { this.title = title; content = new List(); } } public void addLine(String line){ if (!content.find(line)){ content.add(line); } } public void replaceLine(int lineNum,String newContent){ content.replaceContent(lineNum,newContent); } public void remove(int key){ content.remove(key); } public List getContent() { return content; } public abstract void print() {} public String getTitle() { return title; } } public class User extends Wiki { /*private String userID; private List content; public User(String userID) { if (userID.length()<80) { this.userID = userID; content = new List(); } } public void addLine(String line) { if (!content.find(line)) { content.add(line); } } //A method to add to the content of each user public void addUser(String line){ if (!content.find(line)){ content.add(line); System.out.println("NEW USER " + line + " ADDED"); } else{ System.out.println("DUPLICATE USER FOUND"); } } public List getUserList() { return content; } public void print() { System.out.println("The userID is " + userID + " and it contains:"); content.print(); System.out.println(); } } public class Document extends Wiki { private String title; private List content; public Document(String title){ if (title.length()<80) { this.title = title; content = new List(); } } public void addLine(String line){ if (!content.find(line)){ content.add(line); } } public void replaceLine(int lineNum,String newContent){ content.replaceContent(lineNum,newContent); } public void remove(int key){ content.remove(key); } /*public Document(String content){ this.content = content; }*/ public List getContent() { return content; } public void print() { System.out.println("The document title is " + title + " and it contains:"); content.print(); System.out.println(); } public String getTitle() { return title; } } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
