Practice Quiz 3: Software System Design and Client-Server Communication, Quizzes of Computer Science

Material Type: Quiz; Class: Object-Oriented Programming and Design; Subject: COMPUTER SCIENCE; University: University of Arizona; Term: Spring 2007;

Typology: Quizzes

Pre 2010

Uploaded on 08/31/2009

koofers-user-ykt
koofers-user-ykt 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
C Sc 335 Spring 2007 QUIZ 3 postponed to Tuesday 27-Feb __
Practice Quiz 3 Section Leader ____________ Name __________________________ 40 pts max
1. Analyze and design a software system for a video rental store. Simplifying assumptions and details:
Rents only videos, not computer games or other items.
A “video” can be in any medium: tape, DVD, and so on.
The store does not sell anything. For example, there are no sales of videos or food.
Cash-only payments
This is a real store with a real cashier register were transactions are carried out
On completion of a rental, the customer receives a transaction report with ‘typical’ information on it.
Each renter has a separate membership
a) Draw a UML class diagram showing all of your candidate objects and any relationships between
them. Show inheritance relationships, interface implementation, or just general association by just
drawing a line. Write any multiplicity adornment you can think of. You will likely have 1, and or * in a
few places. Include at least one operation in each class. Show at least one attribute in most classes.
(16pts)
b) Write a sequence diagram to represent the objects relationships and messages involved in a scenario that
begins when valid customer arrives at the cashier with one video to rent (assume the store is open and the
cashier is at a cash register). (14pts)
pf2

Partial preview of the text

Download Practice Quiz 3: Software System Design and Client-Server Communication and more Quizzes Computer Science in PDF only on Docsity!

C Sc 335 Spring 2007 QUIZ 3 postponed to Tuesday 27-Feb __

Practice Quiz 3 Section Leader ____________ Name __________________________ 40 pts max

1. Analyze and design a software system for a video rental store. Simplifying assumptions and details:

 Rents only videos, not computer games or other items.

 A “video” can be in any medium: tape, DVD, and so on.

 The store does not sell anything. For example, there are no sales of videos or food.

 Cash-only payments

 This is a real store with a real cashier register were transactions are carried out

 On completion of a rental, the customer receives a transaction report with ‘typical’ information on it.

 Each renter has a separate membership

a) Draw a UML class diagram showing all of your candidate objects and any relationships between

them. Show inheritance relationships, interface implementation, or just general association by just

drawing a line. Write any multiplicity adornment you can think of. You will likely have 1, and or * in a

few places. Include at least one operation in each class. Show at least one attribute in most classes.

(16pts)

b) Write a sequence diagram to represent the objects relationships and messages involved in a scenario that

begins when valid customer arrives at the cashier with one video to rent (assume the store is open and the

cashier is at a cash register). (14pts)

2. Use the following code to answer the three questions below

Server Client on same machine as server

public class QuizServer { public static void main(String[] args) { try { int port = 4000; ServerSocket socket = null ; socket = new ServerSocket(port); Socket connection = socket.accept(); PrintWriter output = new PrintWriter( new OutputStreamWriter( connection.getOutputStream()), true ); BufferedReader input = new BufferedReader( new InputStreamReader( connection.getInputStream())); String str = input.readLine(); System. out .println("fromClient=" + str); output.println("Good bye"); connection.close(); } catch (Exception e) { } } } public class QuizClient { public static void main(String[] args) { try { String IPAddress = "localhost"; int port = 4000; Socket server = new Socket(IPAddress, port); PrintWriter output = new PrintWriter( new OutputStreamWriter( server.getOutputStream()), true ); BufferedReader input = new BufferedReader( new InputStreamReader( server.getInputStream())); output.println("Hello"); String message = input.readLine(); System. out .println("fromServer = "

  • message); server.close(); } catch (Exception e) { } } }

a) To get the client to communicate with the server, which of the two programs should be started first

so no exceptions are thrown ? (2pts)

b) Write the output generated by QuizClient (4pts)

c) Write the output generated by QuizServer (4pts)