CMSC 204 - Testing Service.RAR

CMSC 204 - Testing Service

You will be designing a simple service to administer tests. Your program will consists of two main parts: A. Client – GUI classes. Start this class after the Server is running. B. Server –,,, Start this class before the client. A. CLIENT - The frame and panel make up the client. The client’s job is to: · Create a socket and the input and output streams for that socket · extract data from the user, · ask for services from the server, by “printing” a string to the socket · display data to the user, by “reading” from the socket GUI specifics: · Ask user for their name. · The text area for question should be uneditable. · There four buttons: Check Answer, Next Question, Percent Correct and Exit. · When the next question is displayed, the answer field is cleared · Displays the question number · Once the user has seen all questions and asks for Next Question, display “No more questions in question text area” A. SERVER - The server will consist of the following classes:
Your Test class - CSTest
· Inherits from Test class (I have provided for you) · Contains the test questions and answers – here is an example of the CSTest constructor which you may use in your CSTest class: public CSTest() { super(); questions = new String[11]; questions[0] = ""; questions[1] = "Every node in a binary tree has ____ references."; questions[2] = "In a perfectly balanced binary tree, the height of the left and right subtrees of the root are _____"; questions[3] = "A node in a binary tree is called a(n) ____ if it has no left and right children."; questions[4] = "In a tree, the number of nodes in the longest branch, is called the ____ of the tree"; questions[5] = "Associated with each item in a data set is a special member that uniquely identifies it called a(n) ____."; questions[6] = "In an ordered linked list the search algorithm is somewhat improved because the list is ____."; questions[7] = "A queue is a(n) ____ data structure."; questions[8] = "____ is the ability to create new data types from existing data types."; questions[9] = "When the binding of methods takes place at execution time, it is ____."; questions[10] = "Which operator is used to determine if an object is of a particular class type?"; answers = new String[11]; answers[0] = ""; answers[1] = "2"; answers[2] = "equal"; answers[3] = "leaf"; answers[4] = "height"; answers[5] = "key"; answers[6] = "sorted"; answers[7] = "FIFO"; answers[8] = "inheritance"; answers[9] = "dynamic"; answers[10] = "instanceof"; } · Methods for checking if the answer is correct, displaying the next question and displaying the percent correct
The TestServer class
· Listens for clients · Accepts/creates a socket for each client · Creates a thread for the TestCommandProcessor for each client · Adds the test to the TestManager · I used the 8900 port and it worked fine, you may need to experiment · Start this class first, before the client starts. · When finished, select “display selected console” and click on the TestServer console.
The CSTestCommandProcessor - your TestCommandProcessor class
· Inherits from TestCommandProcessor (I have provided for you) · Constructor requires the socket and a new Test object passed to it · Sets up I/O communication (InputStream and OutputStream) for the socket · Accepts an input string from the client in the following format: Ø “CHECK <answer” Ø “NEXT ” Ø “PERCENT” Ø “QUIT” a. Calls the appropriate method from the Test class b. Returns output to the client You will have two consoles in Eclipse when both the server and the client are running. To switch between consoles, select “Display Selected Console”:
Powered by