Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

82 lines (62 sloc) 1.616 kb
import edu.ucdavis.jr.*;
import java.util.*;
public class Assistant extends Person {
public Assistant() {
super("Assistant");
Global.assistant = this;
knowsOnlyTwoLeft = false;
}
public op void onlyTwoLeft();
private boolean knowsOnlyTwoLeft;
protected boolean shouldGoHome()
{
return knowsOnlyTwoLeft;
}
protected void oneIteration()
{
inni void onlyTwoLeft()
{
clearAllTables();
knowsOnlyTwoLeft = true;
}
[] else
{
clearAllTables();
Sleep.now(Global.assistantNappingTime);
}
}
// This includes cleaning the glasses etc.
private void clearAllTables()
{
say("Starting my clearing round");
List<BeverageWare> glasses = new ArrayList<BeverageWare>();
for(Table t : Global.tables)
{
glasses.addAll(t.clearTable());
}
Sleep.now(glasses.size()*Global.timeItTakesToCleanGlass); // clean glasses
Cupboard cb = Global.cupboard;
for(BeverageWare bw : glasses)
{
cb.putBackItem(bw);
}
}
/***************************************************
TESTING CODE BELOW
***************************************************/
public static void main(String[] args) {
allAssistantTests();
}
public static void allAssistantTests()
{
System.out.println("Assistant tests passed.");
}
public static void asserts(boolean b, String s)
{
if(!b)
{
System.out.println("AssistantAssert failed: " + s);
System.exit(1);
}
}
}
Jump to Line
Something went wrong with that request. Please try again.