Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TV {
- public int width;
- public int height;
- public int depth;
- public int channel = 0;
- public boolean powered = false;
- public TV(int width, int height, int channel) {
- this.width = width;
- this.height = height;
- this.channel = channel;
- }
- public boolean powerOn(boolean powered) {
- if (powered = false) {
- powered = true;
- System.out.println("The TV is now on.");
- } else {
- System.out.println("the TV is already on.");
- }
- return powered;
- }
- public boolean powerOff(boolean powered) {
- if (powered) {
- powered = false;
- }
- return powered;
- }
- public int channelUp() {
- ++channel;
- if (channel > 99) channel = 0;
- return channel;
- }
- public int channelDown() {
- --channel;
- if (channel < 0) channel = 99;
- return channel;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement