Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Utilities.java public class Utilities { public static int DEFAULT_INDENTATION = 3; public static String spaces(int indentation) { String answer = ; for (int i =

Utilities.java public class Utilities { public static int DEFAULT_INDENTATION = 3; public static String spaces(int indentation) { String answer = ""; for (int i = 0; i < indentation; i++) { answer += " "; } return answer; } public static String defaultSpaces(int times) { return spaces(DEFAULT_INDENTATION * times); } /**Writes the provide string to the file. Displays a message indicating the file have been created.*/ public static void writeToFile(String filename, String data) { try { boolean append = false; BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(filename, append)); bufferedWriter.write(data); bufferedWriter.flush(); bufferedWriter.close(); System.out.println("Results can be found in file: " + filename); } catch (IOException e) {System.out.println(e.getMessage()); } } }

Element Interface public interface Element { public String genHTML(int indentation); } WebPage.Java public class WebPage extends Object implements Comparable { /**Initializes the object with the specified title and creates the ArrayList. @param title*/ public WebPage(String title) {} /**Adds an element to the page by adding the element to the end of the ArrayList.Return -1 if the element is not a TagElement; otherwise the id associated with the element. */public int addElement(Element element) { } public String getWebPageHTML(int indentation) { } /**Writes to the specified file the web page page using the provided indentation.Relies on the Utilities method writeToFile*/ public void writeToFile(String filename, int indentation) { } /**Returns a reference to a particular element based on the id Returns reference to element if found and null otherwise*/ public Element findElem(int id) { } /**Returns information about the number of lists, paragraphs, and tables present in the page. Also, it provide table utilization information. See public tests for format.*/public String stats() { } /**compareTo in interface java.lang.Comparable*/ public int compareTo(WebPage webPage) { } /** Enables the ids associated with tag elements. */public static void enableId(boolean choice) { } }

ListElement.java public class ListElement extends TagElement { /**If ordered is true the list will be an ordered list; unordered otherwise. */ public ListElement(boolean ordered, String attributes) { } /**Adds a list item to the end of the list. */ public void addItem(Element item) { } /**Returns a string that represents the HTML associated with the element. The string is indented based on the parameter value */ public String genHTML(int indentation) { }}

TagElement.java public class TagElement implements Element{ /** Initializes a tag element. We can have tag elements with only a start tag. Each time a new tag element is created it is assigned a unique id (starting at 1).*/ public TagElement(String tagName, boolean endTag, Element content, String attributes) { } /**return unique id*/ public int getId() { } /**returns tagname followed by unique id*/ public String getStringId() {} /** Returns the start tag. It will not include the id if inclusion has been disabled. */ public String getStartTag() { } /** Return end tag or empty string (for tags with only start tag).*/public String getEndTag() { } /**Updates attributes field.*/public void setAttributes(String attributes) { } /**Allow us to enable or disable the generation of ids for tags.*/public static void enableId(boolean choice) { } /**Returns a string that represents the HTML associated with the element.*/public String genHTML(int indentation) { }

TableElement.java public class TableElement extends TagElement{ /**Defines the array and initializes the attributes. */ public TableElement(int rows, int cols, String attributes) {} /**Adds/updates the element with the specified indices.*/ public void addItem(int rowIndex, int colIndex, Element item) {} /** Returns the percentage of table cells currently in used (those storing references to objects).*/ public double getTableUtilization() { } public String genHTML(int indentation) { } }

ParagraphElement.java public class TableElement extends TagElement{ /**Defines the array and initializes the attributes. */ public TableElement(int rows, int cols, String attributes) { } /**Adds/updates the element with the specified indices.*/ public void addItem(int rowIndex, int colIndex, Element item) {} /**Returns the percentage of table cells currently in used (those storing references to objects). */ public double getTableUtilization() { } public String genHTML(int indentation) { } }

TextElement.java public class TextElement implements Element { public TextElement(String text) {} public String genHTML(int indentation) {} }

ImageElement.java public class ImageElement extends TagElement { /**Initializes object with the provided parameters.*/public ImageElement(String imageURl, int width, int height, String alt, String attributes) {} public String getImageURL() { }}

AnchorElement.java public class AnchorElement extends TagElement { /**Initializes the tag with the provided parameters. For this project you can assume we will not update any of the attributes associated with this tag. */ public AnchorElement(String url, String linkText, String attributes) { } public String getLinkTest() { } public String getUrlText() { } public String genHTML(int indentation) {} }

Comment if you have question and thank you i will thumbs up For this project develop a set of classes that will support the generation of HTML for web pages.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

Students also viewed these Databases questions

Question

How is K-means clustering different from and similar to KNN?

Answered: 1 week ago