Overview In this assignment, we will be creating an HTML Checker program that will check the syntax of HTML tags. It is similar, but different,from theSyntax Checkerwhich checked matching opening and...

Overview

In this assignment, we will be creating an HTML Checker program that will check the syntax of HTML tags. It is similar, but different,from theSyntax Checkerwhich checked matching opening and closing symbol placement.


You will write a class that stores the contents of an HTML page as a queue of HTMLTags. Your class will also be able to fix invalid HTML tags. Your HTMLManager will use stacks and queues to figure out whether the tags match and fix the mistakes it finds.


There will also be a number of Instructor-provided files to help with this assignment in order to make your work a little less :-)


Topics

queues, stacks


Background on HTML

Web pages are written in a language called “Hypertext Markup Language”, or HTML. An HTML file consists of text surrounded by markings called tags. Tags give information to the text, such as formatting (bold, italic, etc) or layout (paragraph, table, list, etc). Some tags specify comments or information about the document (header, title, document type).


A tag consists of a named element betweenless-thanandgreater-than> symbols.For example, the tag for making text bold uses the elementband is written as.


Many tags apply to a range of text, in which case a pair of tags is used:


An opening tag (indicating the start of the range), which is written as:


A closing tag (indicating the end of the range), which is written as:


So to make some text bold on a page, one would surround the text with opening and closingbtags:


HTML Code:like this


Displayed on screen:like this


Tags can be nested to combine effects. For example:


HTML Code:
like this


Displayed on screen:
like this


Some tags, such as the br tag (which inserts a line break) or the img (which inserts an image), do not cover a range of text and are considered to be “self-closing.” Self-closing tags do not need a closing tag; for a line break, only

is needed. Some web developers write self-closing tags with an optional / before the >, such as

.


Checking HTML

One problem on the web is that many developers make mistakes in their HTML code. All tags that cover a range must eventually be closed, but some developers forget to close their tags. Also, whenever a tag is nested inside another tag,
like this
, the inner tag (ifor italic, here) must be closed before the outer tag is closed. So the following tags are not valid HTML, because the should appear first:
this is invalid


This might sound like a lot if you are unfamiliar with HTML, butDon't stress!You will be provided with an algorithm for checking the validity of a series of HTML tags using stacks and queues.You will just need to follow the algorithm.


Instructions

Part 1: Get the starter files


For this assignment, you are provided with a number of starter files:HTMLChecker.zip



The only file that you will

edit

is HTMLManager.java



The only file that you will

run

is HTMLChecker.java


Thetests/ foldercontains a few test HTML files


Theexpected_output/ foldercontains the expected "fixed" HTML for the associated test files - these are called and compared in the HTMLChecker.java file


The other files you willmostlyjust ignore as they are used from the HTMLChecker, except for HTMLTag.


HTMLTag


There is a provided file called HTMLTag which is the base type for your Queue (and the Stack that you will create in fixHTML), so it is fundamental that you know what methods it contains, though you will not edit it.


An HTMLTag object corresponds to an HTML tag such as


or . An HTMLTag can either be an opening tag, a closing tag, or a self-closing tag. You don’t need to construct HTMLTag objects in your code, but you will process them. The reason we use HTMLTag objects instead of just storing the tags as strings is that the class provides extra functionality that makes processing HTMLTags easier.


In particular, it provides the following methods:



























boolean isOpening()



boolean isClosing()



boolean isSelfClosing()



boolean matches(other)



HTMLTag getMatching()



boolean equals(other)



String toString()



Part 2: build HTMLManager


You need to follow the specification and algorithm below in order to make HTMLChecker work correctly. Additionally,here is a visual walk through of the fixHTML algorithm


Actions.






















Method



HTMLManager(Queue html)



Queue getTags()



String toString()



void fixHTML()


[visual walk through of the algorithm


Actions]



Part 3: Test your HTMLManager using HTMLChecker


Run the HTMLChecker and see if your code passes all the test cases. If it does not - mine didn't on the first few tries ;-), I recommend using the debugger to


set a breakpoint on the loop inside your HTMLManager's fixHTML()


pull out your stack and queue variables from the debug panel


step through your code over and over until you figure out when things go wrong


Here is an example of what your final output will look like:


=============================== Processing tests/test1.html... =============================== HTML:








Checking HTML for errors...

HTML after fix:





 ----> Result matches Expected Output!  =============================== Processing tests/test2.html... =============================== HTML:  Checking HTML for errors...

HTML after fix:  ----> Result matches Expected Output!  =============================== XXXXXXXXXXAll tests passed! =============================== What to Submit

Your completed HTMLManager.java


Please include at the end of this file your final output from HTMLChecker.java


Submission Requirements

You should do the following for _all_ assignments submitted for this course.


ProgramComment


Include a comment at the beginning of your program with the followinginformation and a description of the program in your own words:


// Your name here // CS 143 // HW Core Topics: ... // // This program will ...

Program Output


Include the output from a single run of your program as a block comment at the end ofthe program. This comment should come one blank line after the last closing curly brace in your code.


}

/* Paste the output from JGrasp here. Altering output will earn you an automatic zero for the assignment. */ Rubric

HTML Checker RubricHTML Checker Rubric




























































Criteria




Pts



This criterion is linked to a Learning Outcomeconstructor: handles null parameter



1.0pts



This criterion is linked to a Learning Outcomeconstructor: "remembers" tags that are passed in



1.0pts



This criterion is linked to a Learning OutcomegetTags(): returns tags in the queue



1.0pts



This criterion is linked to a Learning OutcometoString()returns a string representation of the tags in the queue; cycles through queue tags; doesn't change the state of the queue from it's original state; uses trim() to make sure that HTMLChecker will work



4.0pts



This criterion is linked to a Learning OutcomefixHTML(): properly scopes Stack to this method only



1.0pts



This criterion is linked to a Learning OutcomefixHTML(): cycles through all the tags without causing an infinite loop



1.0pts



This criterion is linked to a Learning OutcomefixHTML(): handles self-closing tags properly



2.0pts



This criterion is linked to a Learning OutcomefixHTML(): handles opening tags properly



2.0pts



This criterion is linked to a Learning OutcomefixHTML(): handles closing tags properly



5.0pts



This criterion is linked to a Learning OutcomefixHTML(): handles tags leftover in the stack properly



2.0pts



This criterion is linked to a Learning Outcomestyle / submission requirementsvariable names, indentation, formatting, etc; comments as needed (particularly in the fixHTML() method); header and output provided;



5.0pts



Total Points:25.0



HW #3: Sudoku #3 (solve)" aria-describedby="msf0-previous-desc">Previous HW #5: Josephus Problem">Next



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here