-
Notifications
You must be signed in to change notification settings - Fork 0
S23_RequestInheritance_Easy
YOUR COMPUTER HAS CRASHED AND YOU HAVE LOST YOUR REQUEST INHERITANCE HIERARCHY!!!!!!! All that remains of this catastrophe is your Server class, a DataGenerator class and some old output. Back in the pre-crash days, your server would take in a variety of requests and print diagnostic information about each request. Reverse engineer an inheritance hierarchy that will model different kinds of requests with minimal code repetition.
To start the program and see the diagnostic information for different types of requests run the driver class Server
. This class handles creating one type of each request and printing information about each to the console. To view the same requests with different information simply run the program again.
The program starts in the class Server
which creates a new instance of DataGenerator
and creates a new Stack
containing one of each type of Request
by using random data created by DataGenerator
. DataGenerator
helps create random data for different types of requests through its public methods. Then each request in the stack is popped and information about the class gathered from calls to toString()
for each request and the information is printed to the console. Finally a summary of the number of each request created is printed to the console. Request
and all of the classes which are sub-classes of Request
can be seen in the UML diagram below. Request
and all of it's sub-classes overload the toString()
method to return all of the information pertaining to each request. Request
and all of it's sub-classes also provide a static method count()
which lists the number of instances created throughout the lifetime of the program. This is achieved by a private static member variable count
which is incremented in every constructor.
UML Diagram:
The java documents are served from a local web server on this machine. To start the web server, navigate to the directory immediately above where the source code is checked out (i.e. ~/git ) and then use "python -m SimpleHTTPServer" in that directory.
cd ~/git
python -m SimpleHTTPServer&
Note: if you are running python 3 (which you can check via opening a terminal and typing: python --version), then the command is:
python3 -m http.server