Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Calendar;
- public class Cartoon {
- String name;
- String creator;
- int lastAired;
- Cartoon(String name, String creator, int lastAired) {
- this.name = name;
- this.creator = creator;
- this.lastAired = lastAired;
- giveInfo();
- checkIfStillAiring();
- }
- void giveInfo() {
- System.out.print(name + " is a cartoon created by " + creator + ". ");
- }
- void checkIfStillAiring(){
- int year = Calendar.getInstance().get(Calendar.YEAR);
- boolean stillAiring = (lastAired >= year);
- if (stillAiring) {
- System.out.println("It is still airing.");
- } else {
- System.out.println("It's final episode was released in " + lastAired + ".");
- }
- }
- }
- public class Announcement {
- public static void main(String[] args) {
- Cartoon[] favoriteCartoons = new Cartoon[4];
- favoriteCartoons[0] = new Cartoon("Wander Over Yonder", "Craig McCracken", 2016);
- favoriteCartoons[1] = new Cartoon("Gravity Falls", "Alex Hirsh", 2016);
- favoriteCartoons[2] = new Cartoon("Samurai Jack", "Genndy Tartakovsky", 2017);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement