# Homework 3 – v1 Solution

\$30.00 \$24.90

Category:

## Description

1. You are a given a finite state machine in the attached digital image. Use the state design pattern to implement it in Java and provide a main method where you test all of its transitions. (45 points)

1. Seeing how everybody is using graphs one way or another, you have decided to create a company (“BulutÇizge A.Ş.”) that will provide graph oriented services to the public. In more detail, clients will contact your server, send a graph object to it (+ some parameters), and ask for some computation with it, that your server will realize and return its result(s) to the client. For some unknown reason you have chosen java RMI to implement the communication layer between the server and the clients. Your server provides two services:

a) Given a graph it returns the minimum spanning tree (assume that the graph always contains such a tree if this method is called)

b) The incidence matrix corresponding to the given graph.

What is required of you, are the following:

1. Design and implement the graph data structure, graph algorithms and nodes. Remember that they can represent anything, e.g. cities, people, etc. You want your service to work with ANY kind of data. (30 points)

1. The client, who has some data, will construct her graph using your interface, (so that it’ll be compatible with your server), and call the corresponding method and wait for the output, in order to show it on screen (15 points) (a GUI is optional, +20 points).

1. The server must be waiting at all times for a new method invocation, and have the necessary graph processing methods ready to do the job. Whenever a new request comes it should print on screen which method is called at what time, and how long it took to complete it. (30 points)

1. Free trials are over. Now you are going pro, woohoo!! From now on, any client that wants to use your services must pay for it. In order to achieve this, assume that every client has an account on your server containing a credit amount that allows them to make a certain number of remote method calls. For instance client X has a credit of 100, meaning that she can make 100 remote calls (Does every method cost the same? That’s up to you.). If her credit is zero, she’ll receive an error/exception. Make sure clients authenticate themselves with every remote method call, and decrease their credit accordingly. (40 points) (Optional: implement account creation and credit loading also through RMI, (for instance by providing their credit card information) +20 points). Make sure your server is thread-safe when handling credits, as tens (hundreds?) of remote method calls may happen at the same time.

1. Make sure you test both services (if possible, on different systems) and provide screenshots that they work.

Note: assume your graphs are directed and edge-weighted, and you are free to implement services

1. and (b) with any algorithm you like, except for brute force. It is up to you to model these graphs. Be careful with RMI as the exact procedure depends on your jdk version. Don’t forget the class diagrams.