Assignment 2

Be sure to type up your answers so you can submit them electronically on the BlackBoard Connect system. You may complete this assignment individually. Make sure all your files have your full name and student number on it.

Type up your answers using Eclipse. The file format of the Java program you are to submit must be .java.

This assignment is marked out of 33 points.

Due Date

February 15, 2014, 11:59AM (just before noon).

24 Hour Silence Policy

Due to the large class size and the potential volume of questions, we are implementing a 24-hour silence policy. This means that any questions posted on the discussion forum in the 24 hours immediately preceding the assignment deadline may not get answered in time. This does not mean that we will stop answering questions the moment the day before the deadline arrives, it just means that we cannot promise all the questions will be answered in time, due to our prior engagements, such as other classes and meetings we have.

For this reason, please be sure to attempt the assignment early, and try to complete it as if it were due two days prior to the real deadline.

In any case, we will try to answer all the questions that show up on the discussion forum. Note that questions sent to emails will not be answered, as we want all course related material to be viewed for everyone's benefit.

What You Are Given

There are 2 questions in this assignment. The first question is to practice polymorphism, and the second is on files.

Question 1 [20 points]

You are going to write a program that calculates the price of clothing with the appropriate provincial tax. The store will manage clothing from British Columbia, which has a PST of 7%, and Manitoba, which as a PST of 8%. Moreover, we will have two types of clothing: children and adult. Note that children clothing does not get taxed in any province.

In this question, complete the following:

See sample output from the test class. Save your output into a file called Clothing-Output.txt.

Question 2 [13 points]

Write a simple HTML parser called TagParser that takes an input HTML file, extracts all the words between the an opening and closing pair of "tt" tags, and output those words (without the tags) into a plain text file.

An HTML file is a type of file used for websites. Unlike word, there is no function like boldface or italicize. To specify when a word should be displayed in a different way, tags are used. For example, to make a phrase bold, you would type "< b >a bold phrase< / b >" where "b" stands for bold and the angle brackets denote the tag. (There are no spaces inside the tags when you use them, they are just here for clarity.) In order for a computer to understand the difference between when it should start to bold and when it should stop, an opening tag and a closing tag are used. The closing tag just has an extra "/" in it. In this question, we will work with the HTML tag for "teletype text" (tt for short).

In this question, complete the following:

Note: Be sure to handle your file I/O exceptions in one way or another. If you choose to let it propagate, you must still make sure that one of the caller methods handle it properly, without expecting someone else to handle it for you, and without letting it crash unexpectedly.

See sample file from the test class. There is no output from this class.

What to Submit

Be sure to comment all the methods and attributes for clarity. For this assignment, submit the following: