@Test public void testUpdate() { Pickup pickup = new Pickup(1, 1, ""); int temp = pickup.getXPos(); assertEquals(0, pickup.update(1.0f, 1)); assertTrue(pickup.getXPos() == 0); // Since it subbtracts dt. So 1 - 1 = 0 }
public Set<String> getWasteTypeLabels() { Set<String> ret = new HashSet<String>(); for (Pickup pickup : getPickups()) { ret.add(pickup.getWasteTypeLabel()); } return ret; }
public List<Pickup> getPickupsOnDate(String date) { List<Pickup> pickups = new LinkedList<WastePickupSchedule.Pickup>(); for (Pickup pickup : getPickups()) { if (pickup.getDates().contains(date)) pickups.add(pickup); } return pickups; }
public static Set<String> getWasteTypeLabels(Collection<Pickup> pickups) { Set<String> ret = new HashSet<String>(); for (Pickup pickup : pickups) { ret.add(pickup.getWasteTypeLabel()); } return ret; }
public void addPickupDate(String wasteTypeLabel, Date date) { Pickup pickup = getPickupByWasteTypeLabel(wasteTypeLabel); if (pickup == null) { pickup = new Pickup(wasteTypeLabel); json.addToArray("pickups", pickup.getJson()); } pickup.addDate(date); }
public Date getNextPickupDateByWasteTypeLabel(String wasteTypeLabel) { Pickup pickup = getPickupByWasteTypeLabel(wasteTypeLabel); if (pickup == null) return null; List<String> dates = pickup.getDates(); if (dates.isEmpty()) return null; for (int i = 0; i <= 32; i++) { Date date = Date.inDays(i); String dateAsString = date.toString(); if (dates.contains(dateAsString)) return date; } return null; }
public void removePickupDatesBefore(Date minDate) { boolean pickupRemoved = false; List<Pickup> pickups = getPickups(); for (Pickup pickup : new ArrayList<Pickup>(pickups)) { pickup.removePickupDatesBefore(minDate); if (pickup.getDates().isEmpty()) { pickups.remove(pickup); pickupRemoved = true; } } if (pickupRemoved) putArray("pickups", pickups); }
public int pickupItem(Pickup p) { int value = -1; String pickupName = p.getName().split("_")[0]; if (pickupName.equalsIgnoreCase("Beer") && !p.isPickedUp()) { p.setPickedUp(true); addBeer(); value = 0; } if (pickupName.equalsIgnoreCase("Nozzle") && !p.isPickedUp()) { p.setPickedUp(true); fuelConsumptionRate = 0.55f; value = 1; } if (pickupName.equalsIgnoreCase("Compressor") && !p.isPickedUp()) { p.setPickedUp(true); fuelConsumptionRate = 0.33f; value = 2; } if (pickupName.equalsIgnoreCase("Goal") && !p.isPickedUp()) { value = 3; } return value; }
protected void initialize() { if (!inProgress) { inProgress = true; Pickup.checkArms(); Catapult.latch.set(Latch.UNLOCKED); Timer.delay(0.5); Catapult.setLauncher(RETRACTED); Timer.delay(2.0); Catapult.latch.set(Latch.LOCKED); } }
@Test public void testPickup() { Pickup pickup = new Pickup(1, 1, "unknown"); assertNotNull(pickup); assertEquals("unknown", pickup.getType()); assertEquals(0, pickup.getWidth()); assertEquals(0, pickup.getHeight()); assertEquals(1, pickup.getYPos()); assertEquals(1, pickup.getXPos()); }
protected void execute() { if (!inProgress) { inProgress = true; if (Catapult.latch.get() == Latch.LOCKED) { Catapult.latch.set(Latch.UNLOCKED); Timer.delay(0.2); } if (pwmMode) { Pickup.checkArms(); Catapult.setLauncher(EXTENDED); Timer.delay(0.2); Catapult.setLauncher(RETRACTED); Timer.delay(0.5); } else { Catapult.launchRight.set(EXTENDED); Timer.delay(3.0); Catapult.launchRight.set(RETRACTED); Timer.delay(2.0); } } }
private void prepare() { Session s = openSession(); Transaction txn = s.beginTransaction(); polliwog = new Animal(); polliwog.setBodyWeight(12); polliwog.setDescription("Polliwog"); catepillar = new Animal(); catepillar.setBodyWeight(10); catepillar.setDescription("Catepillar"); frog = new Animal(); frog.setBodyWeight(34); frog.setDescription("Frog"); polliwog.setFather(frog); frog.addOffspring(polliwog); butterfly = new Animal(); butterfly.setBodyWeight(9); butterfly.setDescription("Butterfly"); catepillar.setMother(butterfly); butterfly.addOffspring(catepillar); s.save(frog); s.save(polliwog); s.save(butterfly); s.save(catepillar); Dog dog = new Dog(); dog.setBodyWeight(200); dog.setDescription("dog"); s.save(dog); Cat cat = new Cat(); cat.setBodyWeight(100); cat.setDescription("cat"); s.save(cat); zoo = new Zoo(); zoo.setName("Zoo"); Address add = new Address(); add.setCity("MEL"); add.setCountry("AU"); add.setStreet("Main st"); add.setPostalCode("3000"); zoo.setAddress(add); pettingZoo = new PettingZoo(); pettingZoo.setName("Petting Zoo"); Address addr = new Address(); addr.setCity("Sydney"); addr.setCountry("AU"); addr.setStreet("High st"); addr.setPostalCode("2000"); pettingZoo.setAddress(addr); s.save(zoo); s.save(pettingZoo); Joiner joiner = new Joiner(); joiner.setJoinedName("joined-name"); joiner.setName("name"); s.save(joiner); Car car = new Car(); car.setVin("123c"); car.setOwner("Kirsten"); s.save(car); Truck truck = new Truck(); truck.setVin("123t"); truck.setOwner("Steve"); s.save(truck); SUV suv = new SUV(); suv.setVin("123s"); suv.setOwner("Joe"); s.save(suv); Pickup pickup = new Pickup(); pickup.setVin("123p"); pickup.setOwner("Cecelia"); s.save(pickup); BooleanLiteralEntity bool = new BooleanLiteralEntity(); s.save(bool); txn.commit(); s.close(); }
@Test public void testGetType() { Pickup pickup = new Pickup(1, 1, "unknown"); assertEquals("unknown", pickup.getType()); }
public Pickup getPickupByWasteTypeLabel(String wasteTypeLabel) { for (Pickup pickup : getPickups()) { if (wasteTypeLabel.equals(pickup.getWasteTypeLabel())) return pickup; } return null; }