Package items

Examples of items.Food



    int fordChance = (int)(Math.random()*10 + 1);
   
    if(getDepth() >= 3 || fordChance > 7){
      Food f = World.getWagon().getInventory().getFood();
      if(f.getNumber() > 50)
        f.setNumber(f.getNumber()-20);
      else
        f.setNumber(f.getNumber()-1);
      World.getWagon().setNotification("You forded across the river but lost some food");
      //System.out.println("BAD FORD RESULT");
    }
    else{
      World.getWagon().setNotification("You successfully ford across the river.");
View Full Code Here


    World.getWagon().getInventory().getFood().setNumber(World.getWagon().getInventory().getFood().getNumber()+10);

    int caulkChance = (int)(Math.random()*10 + 1);
   
    if(caulkChance > 4){
      Food f = World.getWagon().getInventory().getFood();
      if(f.getNumber() > 50)
        f.setNumber(f.getNumber()-20);
      else
        f.setNumber(f.getNumber()-1);
      World.getWagon().setNotification("You crossed the river but lost some food");
      //System.out.println("BAD CAULK RESULT");
    }
    else{
      World.getWagon().setNotification("You successfully crossed the river by caulking the wagon");
View Full Code Here

   * @author Stephen Bentley
   */
  @Test
  public void testStoreInitialization(){
    //region 0 with everything available
    assertTrue("Store0 Inventory missing Food", R0Store.getInventory().contains(new Food()));
    assertTrue("Store0 Inventory missing Ammo", R0Store.getInventory().contains(new Ammo()));
    assertTrue("Store0 Inventory missing Water", R0Store.getInventory().contains(new Water()));
    assertTrue("Store0 Inventory missing Medicine", R0Store.getInventory().contains(new Medicine()));
    assertTrue("Store0 Inventory missing Axle", R0Store.getInventory().contains(new Axle()));
    assertTrue("Store0 Inventory missing Clothing", R0Store.getInventory().contains(new Clothing()));
    assertTrue("Store0 Inventory missing Oxen", R0Store.getInventory().contains(new Oxen()));
    assertTrue("Store0 Inventory missing Tongue", R0Store.getInventory().contains(new Tongue()));
    assertTrue("Store0 Inventory missing Wheel", R0Store.getInventory().contains(new Wheel()));
    //region 1 with most things available
    assertTrue("Store1 Inventory missing Food", R1Store.getInventory().contains(new Food()));
    assertTrue("Store1 Inventory missing Ammo", R1Store.getInventory().contains(new Ammo()));
    assertTrue("Store1 Inventory missing Water", R1Store.getInventory().contains(new Water()));
    assertTrue("Store1 Inventory missing Medicine", R1Store.getInventory().contains(new Medicine()));
    assertTrue("Store1 Inventory missing Axle", R1Store.getInventory().contains(new Axle()));
    assertFalse("Store1 Inventory not missing Clothing", R1Store.getInventory().contains(new Clothing()));
    assertTrue("Store1 Inventory missing Oxen", R1Store.getInventory().contains(new Oxen()));
    assertTrue("Store1 Inventory missing Tongue", R1Store.getInventory().contains(new Tongue()));
    assertFalse("Store1 Inventory not missing Wheel", R1Store.getInventory().contains(new Wheel()));
    //region 2 with less available
    assertTrue("Store2 Inventory missing Food", R2Store.getInventory().contains(new Food()));
    assertTrue("Store2 Inventory missing Ammo", R2Store.getInventory().contains(new Ammo()));
    assertFalse("Store2 Inventory not missing Water", R2Store.getInventory().contains(new Water()));
    assertFalse("Store2 Inventory not missing Medicine", R2Store.getInventory().contains(new Medicine()));
    assertTrue("Store2 Inventory missing Axle", R2Store.getInventory().contains(new Axle()));
    assertTrue("Store2 Inventory missing Clothing", R2Store.getInventory().contains(new Clothing()));
    assertFalse("Store2 Inventory not missing Oxen", R2Store.getInventory().contains(new Oxen()));
    assertFalse("Store2 Inventory not missing Tongue", R2Store.getInventory().contains(new Tongue()));
    assertTrue("Store2 Inventory missing Wheel", R2Store.getInventory().contains(new Wheel()));
    //region 3 with almost nothing available
    assertTrue("Store3 Inventory missing Food", R3Store.getInventory().contains(new Food()));
    assertFalse("Store3 Inventory not missing Ammo", R3Store.getInventory().contains(new Ammo()));
    assertFalse("Store3 Inventory not missing Water", R3Store.getInventory().contains(new Water()));
    assertTrue("Store3 Inventory missing Medicine", R3Store.getInventory().contains(new Medicine()));
    assertFalse("Store3 Inventory not missing Axle", R3Store.getInventory().contains(new Axle()));
    assertFalse("Store3 Inventory not missing Clothing", R3Store.getInventory().contains(new Clothing()));
View Full Code Here

   */
  public Inventory(){
    length = 9;
    itemInventory = new Item[length];
    itemInventory[0] = new Ammo();
    itemInventory[1] = new Food();
    itemInventory[2] = new Medicine();
    itemInventory[3] = new Water();
    itemInventory[4] = new Axle();
    itemInventory[5] = new Clothing();
    itemInventory[6] = new Oxen();
View Full Code Here

  /**
   * Returns the Food object in the Inventory if it exists, if not returns null
   * @return Food or null depending on the presence of a Food object in inventory
   */
  public Food getFood(){
    if(itemInventory[1].equals(new Food()))
      return (Food) itemInventory[1];
   
    for (int f=0; f<length; f++){
      if (itemInventory[f].equals(new Food())){
        return (Food) itemInventory[f];
      }
    }
    return null;
  }
View Full Code Here

   * based on the pace, ration rate, and water rate respectively
   *
   */
  public void takeStep()
  {
    Food f = inventory.getFood();
    Water w = inventory.getWater();
    leader.live(); //Live dammnit LIVE!
    for(Traveler t : members) {
      t.live();
    }
    //check if anyone's still alive
    boolean alive = false;
    for(Person p : this.getPassengers()) {
      if(p.getHealth() > 0)
        alive = true;
    }
    if(!alive && !World.getMainScreen().getLightning()) {
      lose = true;
      World.getMainScreen().displayOnLose("Everyone died!");
    }else if(leader.getHealth()<=0 && !World.getMainScreen().getLightning()){
      lose = true;
      World.getMainScreen().displayOnLose("The leader died!");
    }else if(World.getMainScreen().getLightning()){
      lose = true;
      World.getMainScreen().displayOnLose(("Your wagon was struck by a random lighting bolt...none survived."));
    }
    if(inventory.getOxen().getNumber() > 0 && !isWheelBroken && !isAxleBroken && !isTongueBroken){
      distance += pace;
      townDistance += pace;
      int weight = 0;
      for(int i = 0; i<inventory.getLength();i++){
        weight += inventory.getItem(i).getWeight()*inventory.getItem(i).getNumber();
      }
      setTotalWeight(weight);
    }else{
      if(inventory.getOxen().getNumber()<=0){
        World.getMainScreen().displayOnField("You don't have even one ox!");
      }else if(isWheelBroken){
        World.getMainScreen().displayOnField("You have a broken wagon wheel!");
      }else if(isAxleBroken){
        World.getMainScreen().displayOnField("You have a broken axle on your wagon!");
      }else if(isTongueBroken){
        World.getMainScreen().displayOnField("You have a broken tongue on your oxen!");
      }
    }
    World.nextDay();
   
    f.use();
    //w.use();
   
    //System.out.println(this+" print from wagon turn");
  }
View Full Code Here

TOP

Related Classes of items.Food

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.