Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. public class TV {
  2.  
  3.  
  4. public int width;
  5. public int height;
  6. public int depth;
  7. public int channel = 0;
  8. public boolean powered = false;
  9.  
  10. public TV(int width, int height, int channel) {
  11. this.width = width;
  12. this.height = height;
  13. this.channel = channel;
  14. }
  15.  
  16. public boolean powerOn(boolean powered) {
  17. if (powered = false) {
  18. powered = true;
  19. System.out.println("The TV is now on.");
  20. } else {
  21. System.out.println("the TV is already on.");
  22. }
  23. return powered;
  24. }
  25.  
  26. public boolean powerOff(boolean powered) {
  27. if (powered) {
  28. powered = false;
  29. }
  30. return powered;
  31. }
  32.  
  33. public int channelUp() {
  34. ++channel;
  35. if (channel > 99) channel = 0;
  36. return channel;
  37. }
  38.  
  39. public int channelDown() {
  40. --channel;
  41. if (channel < 0) channel = 99;
  42. return channel;
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement