SHARE
TWEET

Driver.java

a guest Sep 19th, 2019 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package lab01;
  2.  
  3. /**
  4.  * Driver class
  5.  * Runs the full project
  6.  * @author Chad Humphries
  7.  * @version lab01
  8.  * Date Created: Sept 14, 2019
  9.  */
  10. public class Driver
  11. {
  12.     /**
  13.      * Default Constructor
  14.      */
  15.     private Driver()
  16.     {
  17.     }
  18.    
  19.     /**
  20.      * Main method
  21.      * @param args console arguments
  22.      */
  23.     public static void main(String[] args)
  24.     {
  25.         Forest forest = new Forest();
  26.        
  27.         //Create and plant trees
  28.         forest.plant(new Tree());
  29.         forest.plant(new Tree());
  30.         forest.plant(new Tree("", 5, 1758));
  31.         forest.plant(new Tree("Oak", 6, 2017));
  32.         forest.plant(new Tree("Birch", -3, 2017));
  33.         forest.plant(new Tree("Oak", 6, 1993));
  34.         forest.plant(new Tree("Fir", 13, 2020));
  35.         forest.plant(new Tree(null, 8, 2003));
  36.         forest.plant(new Tree(" ", 1, 1758));
  37.         forest.plant(new Tree());
  38.        
  39.         //Check all data on trees, attempt a search
  40.         forest.showTrees();
  41.         forest.showTreesByYear(2017);
  42.         System.out.println("Number of trees: " + forest.numberOfTrees());
  43.        
  44.         //Remove some trees and check again
  45.         forest.removeTreesByYear(2017);
  46.         forest.showTrees();
  47.         System.out.println("Number of trees: " + forest.numberOfTrees());
  48.        
  49.         //Add a new tree and check once more
  50.         forest.plant(new Tree("Acacia", 3, 1993));
  51.         forest.showTrees();
  52.         forest.showTreesByYear(1993);
  53.         System.out.println("Number of trees: " + forest.numberOfTrees());
  54.     }
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top