NadezhdaGeorgieva

Main

Feb 18th, 2021
915
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package rabbits;
  2.  
  3. import java.util.List;
  4.  
  5. public class Main {
  6.     public static void main(String[] args) {
  7. //Initialize the repository (Cage)
  8.         Cage cage = new Cage("Wildness", 20);
  9.         //Initialize entity
  10.         Rabbit rabbit = new Rabbit("Fluffy", "Blanc de Hotot");
  11.         //Print Rabbit
  12.         System.out.println(rabbit); // Rabbit (Blanc de Hotot): Fluffy
  13.  
  14. //Add Rabbit
  15.         cage.add(rabbit);
  16.         System.out.println(cage.count()); //1
  17. //Remove Rabbit
  18.         cage.removeRabbit("Rabbit Name"); //false
  19.  
  20.         Rabbit secondRabbit = new Rabbit("Bunny", "Brazilian");
  21.         Rabbit thirdRabbit = new Rabbit("Jumpy", "Cashmere Lop");
  22.         Rabbit fourthRabbit = new Rabbit("Puffy", "Cashmere Lop");
  23.         Rabbit fifthRabbit = new Rabbit("Marlin", "Brazilian");
  24.  
  25. //Add Rabbits
  26.         cage.add(secondRabbit);
  27.         cage.add(thirdRabbit);
  28.         cage.add(fourthRabbit);
  29.         cage.add(fifthRabbit);
  30.  
  31. //Sell Rabbit by name
  32.         System.out.println(cage.sellRabbit("Bunny")); //Rabbit (Brazilian): Bunny
  33. //Sell Rabbit by species
  34.         List<Rabbit> soldSpecies = cage.sellRabbitBySpecies("Cashmere Lop");
  35.  
  36.         soldSpecies.forEach(f-> {
  37.             System.out.println(f.getName());
  38.  
  39.         });
  40.         //Jumpy
  41.         //Puffy
  42.  
  43.         System.out.println(cage.report());
  44. //Rabbits available at Wildness:
  45. //Rabbit (Blanc de Hotot): Fluffy
  46. //Rabbit (Brazilian): Marlin
  47.     }
  48. }
  49.  
RAW Paste Data