Advertisement
joxaren

Cartoon

Apr 7th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. import java.util.Calendar;
  2.  
  3. public class Cartoon {
  4.     String name;
  5.     String creator;
  6.     int lastAired;
  7.  
  8.     Cartoon(String name, String creator, int lastAired) {
  9.         this.name = name;
  10.         this.creator = creator;
  11.         this.lastAired = lastAired;
  12.         giveInfo();
  13.         checkIfStillAiring();
  14.     }
  15.  
  16.     void giveInfo() {
  17.         System.out.print(name + " is a cartoon created by " + creator + ". ");
  18.     }
  19.     void checkIfStillAiring(){
  20.         int year = Calendar.getInstance().get(Calendar.YEAR);
  21.         boolean stillAiring = (lastAired >= year);
  22.         if (stillAiring) {
  23.             System.out.println("It is still airing.");
  24.         } else {
  25.             System.out.println("It's final episode was released in " + lastAired + ".");
  26.         }
  27.     }
  28. }
  29.  
  30. public class Announcement {
  31.     public static void main(String[] args) {
  32.         Cartoon[] favoriteCartoons = new Cartoon[4];
  33.         favoriteCartoons[0] = new Cartoon("Wander Over Yonder", "Craig McCracken", 2016);
  34.         favoriteCartoons[1] = new Cartoon("Gravity Falls", "Alex Hirsh", 2016);
  35.         favoriteCartoons[2] = new Cartoon("Samurai Jack", "Genndy Tartakovsky", 2017);
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement