// Helene Martin, CSE 142 // Hipsters all meet at the bar with the cheapest PBR. // The first Hipster object created chooses the bar which // is SHARED between all Hipster instances. Static fields // are always shared this way. import java.util.*; public class Hipster extends Critter { private static int barX = -1; private static int barY = -1; public Hipster() { // if it's the first Hipster, pick the bar if (barX < 0 && barY < 0) { Random r = new Random(); barX = r.nextInt(60); barY = r.nextInt(50); } } public Direction getMove() { if (getY() != barY) { return Direction.NORTH; } if (getX() != barX) { return Direction.EAST; } return Direction.CENTER; } }