Professional Documents
Culture Documents
I Class:......................................................................Student ID:......................................................................Order:
[ Date of E xam:..................................................................................................................
FINAL EXAM
Question 2. (2 points) ^^
With the following three classes, which lines have compiling errors? Explain? How to fix the errors?
4- }
5. abstract class HuaweiSmartDevice extends SmartDevice {
6. protected long modelNumber;
12. }
13.)
Question 3. (2 points)
It is required to develop software to crawl online articles. Each article has the
following attributes: title, description, content in the form of Text/HTML, list
of related tags, author, and the date it is written. Tags have parent-child
relationships. For example, the sport tag is the parent of the football tag, the
football tag is the parent of the v-leage tag.
The software collects articles from 2 websites, dantri.vn and 24h.com.vn. In the future, it may expand to many other websites.
Currently the software collect articles in 2 categories only: sport and travel. Note that the category is independent of the tag.
For each category and for each website, the article structure is different. Thus, we need a separate crawler for each. The
collected articles will be stored as a list. In the future, it will be stored in database management systems.
The craw ler manager controls the crawling process. The manager can add/remove crawlers. It is possible to ask crawlers to
collect articles written on a specific date. The crawler manager integrates 3 reporting features. Any reporting feature can be
called. Report 1: print out the total number of articles collected for each website. Report 2: print out the total number of articles
collected by each category. Report 3: print out the total number of articles collected under any input tag. Note: assume the input
tag is sport, you need to get all articles associated with the sport tag, and all articles associated with any tag that is a child of this
sport tag.
Requirements: the software should be easy to extend. When you need to add new websites, tags, reporting features, you can
add them easily; the source code that need to be modified should be as little as possible.
Hint: Tags should be modeled by String rather than classes. The parent-child relationship among tags is managed in the
TagManager class, in which it is possible to add a pair of tags (which includes the parent tag and the child tag), to get a list of child
tags of an input tag, and to get a list of parent tags of an input tag.
a) Design classes and draw class diagrams for the software (3 points)
b) Explain the OOP techniques used in your design to make it easy for the software to add new reporting feature When we add a
new reporting feature, how should the software be modified (1 point)
c) Write source code for the TagManager class (1 point)
d) Write source code for Reporting feature 2. Assuming class X is the class containing Reporting feature 2 you need o write code
for class X and the code elements directly related to this feature. Other code elements in X can be ignored.
END