Created
March 31, 2020 04:17
-
-
Save eleanor-em/4d97272ff22b8890ba2b8c3492750ad9 to your computer and use it in GitHub Desktop.
TvNetwork example with Show class for SWEN20003.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Show { | |
private String name; | |
private String airTime; | |
public Show(String name, int hour, int minute) { | |
if (hour < 0 || hour > 24) { | |
System.out.println("warning: invalid hour: " + hour); | |
} | |
if (minute < 0 || minute > 59) { | |
System.out.println("warning: invalid minute: " + minute); | |
} | |
this.name = name; | |
airTime = String.format("%02d:%02d", hour, minute); | |
} | |
public String toString() { | |
return String.format("%s airing at %s", name, airTime); | |
} | |
} | |
public class TvNetwork { | |
public static void main(String[] args) { | |
Show show = new Show("7:30", 19, 30); | |
System.out.println(show); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment