Exemplo n.º 1
0
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    Player p1 = new Player("Bob");

    System.out.println(p1.name + ", You came across an item. +10 health!");
    p1.boostHealth(100);
    System.out.println("Your health is now " + p1.health);
    System.out.println(p1.strength);

    Item i1 = new Item("sword", 0, 10);
    i1.boost(p1);
    System.out.println(p1.strength);

    Poison i2 = new Poison();
    System.out.println("You came across Poison!");
    i2.boost(p1);
    System.out.println(p1.health);

    System.out.println(p1.isAlive());

    // Instant kill the player
    System.out.println("You stepped on a snake!");
    p1.health = p1.health - p1.health;

    System.out.println(p1.isAlive());
    System.out.println("You are dead!");
    clearscreen();
    System.out.println("You are a clear screen");

    p1.health += 100;
    Enemy e1 = new Enemy("qoB");

    Shirt s1 = new Shirt();
    s1.boost(p1);

    // e1.fight(p1);

    // make empty array
    Enemy[] enemyArray = new Enemy[5]; // Array holds 5 enemies

    // fills the enemy array
    for (int i = 0; i < enemyArray.length; i++) {
      enemyArray[i] = new Enemy("qoB" + i);
    }

    // fight every single enemy in this array
    for (int i = 0; i < enemyArray.length; i++) {
      enemyArray[i].fight(p1);
      p1.obliterateNum += 5;
    }
  }
Exemplo n.º 2
0
  public static void main(String[] args) throws FileNotFoundException {
    // TODO Auto-generated method stub

    ShirtCRUD list;

    list = openFile(); // initializare tricouri

    HashMap<Integer, Shirt> map = new HashMap<Integer, Shirt>();

    for (Shirt s : list.shirtList) // tricouri->hashmap
    map.put(s.getID(), s);

    TranzCRUD tranz;
    // tranz.map = map; // hashmapul din tranzitii ptr verificare

    tranz = tranzFile(map); // citesc tranzactiile

    int k = 0; // contor ptr nr de tranzactii efectuate
    int q = 3; // dupa q tranzactii se afiseaza rapoartele

    for (Transaction t : tranz.tranzList) System.out.println(t);

    System.out.println();
    System.out.println();
    System.out.println();

    for (Transaction t : tranz.tranzList) {

      try {

        t.process(map);
        k++;
      } catch (Exception e) {
        // e.printStackTrace();
      }

      if (k % q == 0 && k != 0) {
        list.shirtList.sort(new ComparatorA());
        for (Shirt s : list.shirtList) System.out.println(s);

        Collections.sort(list.shirtList);
        for (Shirt s : list.shirtList) System.out.println(s);
      }
    }
  }