package edu.gac.max.gened; public class TestClient { // An example of how this program would be used (should be one line): // // java edu.gac.max.gened.TestClient rmi://kilpinen.mcs.gac.edu/max-gened // BD M1 W1 F1 M2 W2 F2 T3 R3 // // This would ask for courses satisfying area B and/or area D and avoiding // 1st period MWF, 2nd period MWF, and 3rd period TR. Also, it indicates // that the server is on kilpinen.mcs.gac.edu, bound to the name max-gened. // Limitation: The way the command line arguments are parsed, // only single character geneds can be handled (no LD or GN). public static void main(String[] commandLineArgs){ if(commandLineArgs.length < 2){ System.err.println ("Usage: java edu.gac.max.gened.TestClient serverURL geneds" + " conflict ..."); System.exit(1); } String[] geneds = new String[commandLineArgs[1].length()]; for(int i = 0; i < commandLineArgs[1].length(); i++){ geneds[i] = commandLineArgs[1].substring(i, i+1); } Conflict[] conflicts = new Conflict[commandLineArgs.length - 2]; for(int i = 2; i < commandLineArgs.length; i++){ conflicts[i-2] = new Conflict(commandLineArgs[i].charAt(0), commandLineArgs[i].charAt(1)); } if (System.getSecurityManager() == null) { System.setSecurityManager(new java.rmi.RMISecurityManager()); } try{ Server s = (Server) java.rmi.Naming.lookup(commandLineArgs[0]); Course[] courses = s.satisfyAnyAndAvoid(geneds, conflicts); for(int i = 0; i < courses.length; i++){ Course c = courses[i]; System.out.println(c.getDepartment() + c.getNumber() + c.getSection() + ", " + c.getDescription() + ", satisfies " + c.getGeneds() + ", meets " + c.getDays() + " " + c.getPeriods()); } } catch(Exception e){ System.err.println(e); System.exit(1); } } }