Skip to content

Commit b7ac0c2

Browse files
committed
fix indentation project-wide
1 parent 7bb64b1 commit b7ac0c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3804
-4208
lines changed

code/Client/Client/Client.java

Lines changed: 423 additions & 442 deletions
Large diffs are not rendered by default.

code/Client/Client/Command.java

Lines changed: 49 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,65 @@
11
package Client;
22

33
public enum Command {
4-
Help("List all available commands", "[CommandName]"),
4+
Help("List all available commands", "[CommandName]"),
55

6-
AddFlight("Add a new flight number", "<xid>,<FlightNumber>,<NumberOfSeats>,<PricePerSeat>"),
7-
AddCars("Add a new car location", "<xid>,<Location>,<NumberOfCar>,<Price>"),
8-
AddRooms("Add a new room location", "<xid>,<Location>,<NumberOfRoom>,<Price>"),
9-
AddCustomer("Generate a new customer id", "<xid>"),
10-
AddCustomerID("Create a new customer with the id", "<xid>,<CustomerID>"),
6+
AddFlight("Add a new flight number", "<xid>,<FlightNumber>,<NumberOfSeats>,<PricePerSeat>"),
7+
AddCars("Add a new car location", "<xid>,<Location>,<NumberOfCar>,<Price>"),
8+
AddRooms("Add a new room location", "<xid>,<Location>,<NumberOfRoom>,<Price>"),
9+
AddCustomer("Generate a new customer id", "<xid>"),
10+
AddCustomerID("Create a new customer with the id", "<xid>,<CustomerID>"),
1111

12-
DeleteFlight("Delete a flight number", "<xid>,<FlightNumber>"),
13-
DeleteCars("Delete all cars at a location", "<xid>,<Location>"),
14-
DeleteRooms("Delete all rooms at a location", "<xid>,<Location>"),
15-
DeleteCustomer("Delete a customer (and return all reservations)", "<xid>,<CustomerID>"),
12+
DeleteFlight("Delete a flight number", "<xid>,<FlightNumber>"),
13+
DeleteCars("Delete all cars at a location", "<xid>,<Location>"),
14+
DeleteRooms("Delete all rooms at a location", "<xid>,<Location>"),
15+
DeleteCustomer("Delete a customer (and return all reservations)", "<xid>,<CustomerID>"),
1616

17-
QueryFlight("Query the number of available seats on a flight number", "<xid>,<FlightNumber>"),
18-
QueryCars("Query the number of available cars at a location", "<xid>,<Location>"),
19-
QueryRooms("Query the number of available rooms at a location", "<xid>,<Location>"),
20-
QueryCustomer("Query a customer's bill", "<xid>,<CustomerID>"),
17+
QueryFlight("Query the number of available seats on a flight number", "<xid>,<FlightNumber>"),
18+
QueryCars("Query the number of available cars at a location", "<xid>,<Location>"),
19+
QueryRooms("Query the number of available rooms at a location", "<xid>,<Location>"),
20+
QueryCustomer("Query a customer's bill", "<xid>,<CustomerID>"),
2121

22-
QueryFlightPrice("Query the price per seat on a flight number", "<xid>,<FlightNumber>"),
23-
QueryCarsPrice("Query the price per car at a location", "<xid>,<Location>"),
24-
QueryRoomsPrice("Query the price per room at a location", "<xid>,<Location>"),
22+
QueryFlightPrice("Query the price per seat on a flight number", "<xid>,<FlightNumber>"),
23+
QueryCarsPrice("Query the price per car at a location", "<xid>,<Location>"),
24+
QueryRoomsPrice("Query the price per room at a location", "<xid>,<Location>"),
2525

26-
ReserveFlight("Reserve a flight number for a customer", "<xid>,<CustomerID>,<FlightNumber>"),
27-
ReserveCar("Reserve a car for a customer at a location", "<xid>,<CustomerID>,<Location>"),
28-
ReserveRoom("Reserve a room for a customer at a location", "<xid>,<CustomerID>,<Location>"),
26+
ReserveFlight("Reserve a flight number for a customer", "<xid>,<CustomerID>,<FlightNumber>"),
27+
ReserveCar("Reserve a car for a customer at a location", "<xid>,<CustomerID>,<Location>"),
28+
ReserveRoom("Reserve a room for a customer at a location", "<xid>,<CustomerID>,<Location>"),
2929

30-
Bundle("Book N flight numbers, and optionally a room and/or car at a location", "<xid>,<CustomerID>,<FlightNumber1>...<FlightNumberN>,<Location>,<Car-Y/N>,<Room-Y/N>"),
30+
Bundle("Book N flight numbers, and optionally a room and/or car at a location", "<xid>,<CustomerID>,<FlightNumber1>...<FlightNumberN>,<Location>,<Car-Y/N>,<Room-Y/N>"),
3131

32-
Quit("Exit the client application", "");
32+
Quit("Exit the client application", "");
3333

34-
String m_description;
35-
String m_args;
34+
String m_description;
35+
String m_args;
3636

37-
Command(String p_description, String p_args)
38-
{
39-
m_description = p_description;
40-
m_args = p_args;
41-
}
37+
Command(String p_description, String p_args) {
38+
m_description = p_description;
39+
m_args = p_args;
40+
}
4241

43-
public static Command fromString(String string)
44-
{
45-
for (Command cmd : Command.values())
46-
{
47-
if (cmd.name().equalsIgnoreCase(string))
48-
{
49-
return cmd;
50-
}
51-
}
52-
throw new IllegalArgumentException("Command " + string + " not found");
53-
}
42+
public static Command fromString(String string) {
43+
for (Command cmd : Command.values()) {
44+
if (cmd.name().equalsIgnoreCase(string)) {
45+
return cmd;
46+
}
47+
}
48+
throw new IllegalArgumentException("Command " + string + " not found");
49+
}
5450

55-
public static String description()
56-
{
57-
String ret = "Commands supported by the client:\n";
58-
for (Command cmd : Command.values())
59-
{
60-
ret += "\t" + cmd.name() + "\n";
61-
}
62-
ret += "use help,<CommandName> for more detailed information";
63-
return ret;
64-
}
51+
public static String description() {
52+
String ret = "Commands supported by the client:\n";
53+
for (Command cmd : Command.values()) {
54+
ret += "\t" + cmd.name() + "\n";
55+
}
56+
ret += "use help,<CommandName> for more detailed information";
57+
return ret;
58+
}
6559

66-
public String toString()
67-
{
68-
String ret = name() + ": " + m_description + "\n";
69-
ret += "Usage: " + name() + "," + m_args;
70-
return ret;
71-
}
60+
public String toString() {
61+
String ret = name() + ": " + m_description + "\n";
62+
ret += "Usage: " + name() + "," + m_args;
63+
return ret;
64+
}
7265
}

code/Client/Client/RMIClient.java

Lines changed: 61 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -10,84 +10,72 @@
1010
import java.util.*;
1111
import java.io.*;
1212

13-
public class RMIClient extends Client
14-
{
15-
private static String s_serverHost = "localhost";
16-
private static int s_serverPort = 2005;
17-
private static String s_serverName = "MiddlewareServer";
13+
public class RMIClient extends Client {
14+
private static String s_serverHost = "localhost";
15+
private static int s_serverPort = 2005;
16+
private static String s_serverName = "MiddlewareServer";
1817

19-
//TODO: REPLACE 'ALEX' WITH YOUR GROUP NUMBER TO COMPILE
20-
private static String s_rmiPrefix = "group25_";
18+
//TODO: REPLACE 'ALEX' WITH YOUR GROUP NUMBER TO COMPILE
19+
private static String s_rmiPrefix = "group25_";
2120

22-
public static void main(String args[])
23-
{
24-
if (args.length > 0)
25-
{
26-
s_serverHost = args[0];
27-
}
28-
if (args.length > 1)
29-
{
30-
s_serverName = args[1];
31-
}
32-
if (args.length > 2)
33-
{
34-
System.err.println((char)27 + "[31;1mClient exception: " + (char)27 + "[0mUsage: java client.RMIClient [server_hostname [server_rmiobject]]");
35-
System.exit(1);
36-
}
21+
public static void main(String args[]) {
22+
if (args.length > 0) {
23+
s_serverHost = args[0];
24+
}
25+
if (args.length > 1) {
26+
s_serverName = args[1];
27+
}
28+
if (args.length > 2) {
29+
System.err.println((char) 27 + "[31;1mClient exception: " + (char) 27 + "[0mUsage: java client.RMIClient [server_hostname [server_rmiobject]]");
30+
System.exit(1);
31+
}
3732

38-
// Set the security policy
39-
if (System.getSecurityManager() == null)
40-
{
41-
System.setSecurityManager(new SecurityManager());
42-
}
33+
// Set the security policy
34+
if (System.getSecurityManager() == null) {
35+
System.setSecurityManager(new SecurityManager());
36+
}
4337

44-
// Get a reference to the RMIRegister
45-
try {
46-
RMIClient client = new RMIClient();
47-
client.connectServer();
48-
client.start();
49-
}
50-
catch (Exception e) {
51-
System.err.println((char)27 + "[31;1mClient exception: " + (char)27 + "[0mUncaught exception");
52-
e.printStackTrace();
53-
System.exit(1);
54-
}
55-
}
38+
// Get a reference to the RMIRegister
39+
try {
40+
RMIClient client = new RMIClient();
41+
client.connectServer();
42+
client.start();
43+
} catch (Exception e) {
44+
System.err.println((char) 27 + "[31;1mClient exception: " + (char) 27 + "[0mUncaught exception");
45+
e.printStackTrace();
46+
System.exit(1);
47+
}
48+
}
5649

57-
public RMIClient()
58-
{
59-
super();
60-
}
50+
public RMIClient() {
51+
super();
52+
}
6153

62-
public void connectServer()
63-
{
64-
connectServer(s_serverHost, s_serverPort, s_serverName);
65-
}
54+
public void connectServer() {
55+
connectServer(s_serverHost, s_serverPort, s_serverName);
56+
}
6657

67-
public void connectServer(String server, int port, String name)
68-
{
69-
try {
70-
boolean first = true;
71-
while (true) {
72-
try {
73-
Registry registry = LocateRegistry.getRegistry(server, port);
74-
m_resourceManager = (IResourceManager)registry.lookup(s_rmiPrefix + name);
75-
System.out.println("Connected to '" + name + "' server [" + server + ":" + port + "/" + s_rmiPrefix + name + "]");
76-
break;
77-
}
78-
catch (NotBoundException|RemoteException e) {
79-
if (first) {
80-
System.out.println("Waiting for '" + name + "' server [" + server + ":" + port + "/" + s_rmiPrefix + name + "]");
81-
first = false;
82-
}
83-
}
84-
Thread.sleep(500);
85-
}
86-
}
87-
catch (Exception e) {
88-
System.err.println((char)27 + "[31;1mServer exception: " + (char)27 + "[0mUncaught exception");
89-
e.printStackTrace();
90-
System.exit(1);
91-
}
92-
}
58+
public void connectServer(String server, int port, String name) {
59+
try {
60+
boolean first = true;
61+
while (true) {
62+
try {
63+
Registry registry = LocateRegistry.getRegistry(server, port);
64+
m_resourceManager = (IResourceManager) registry.lookup(s_rmiPrefix + name);
65+
System.out.println("Connected to '" + name + "' server [" + server + ":" + port + "/" + s_rmiPrefix + name + "]");
66+
break;
67+
} catch (NotBoundException | RemoteException e) {
68+
if (first) {
69+
System.out.println("Waiting for '" + name + "' server [" + server + ":" + port + "/" + s_rmiPrefix + name + "]");
70+
first = false;
71+
}
72+
}
73+
Thread.sleep(500);
74+
}
75+
} catch (Exception e) {
76+
System.err.println((char) 27 + "[31;1mServer exception: " + (char) 27 + "[0mUncaught exception");
77+
e.printStackTrace();
78+
System.exit(1);
79+
}
80+
}
9381
}

0 commit comments

Comments
 (0)