Write bunch of java to solve a series of requirements and pass a series of tests to prove your code works the way it should.

WriteIFs.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**
  2. * Write a description of class WriteIFs here.
  3. *
  4. * @author (your name)
  5. * @version (a version number or a date)
  6. */
  7. public class WriteIFs
  8. {
  9. int x;
  10. int tt_t;
  11. int tt_s;
  12. int oo1, oo2;
  13. String ss;
  14. /**
  15. * Constructor for objects of class WriteIFs
  16. */
  17. public WriteIFs()
  18. {
  19. // initialise instance variables
  20. x = 0;
  21. tt_t = 0;
  22. tt_s = 1;
  23. ss = "";
  24. oo1 = 61;
  25. oo2 = 49;
  26. }
  27. //public boolean playerDied(boolean player1) {
  28. // Write an IF statement that checks “player1.isAlive()”
  29. // and if that’s false, calls “displayGameOver(player1)”
  30. // if (player1.isAlive()) {
  31. // return displayGameOver(player1);
  32. // }
  33. //}
  34. public String thermoSTAT(int room) {
  35. // Write an IF statement that checks the
  36. // “temperature(room)” and if that check is less than 70,
  37. // calls “heatOn()” else calls “coolOn()”
  38. if (tempurature(room) < 70) {
  39. heatOn();
  40. } else {
  41. coolOn();}
  42. return this.ss;
  43. }
  44. public void fireplaceControl(Object fireplace1) {
  45. // Write an IF statement that checks
  46. // “outsideTemp()” is less than 50
  47. // AND
  48. // “insideTemp()” is less than 62,
  49. // calls “startAFire(fireplace1)”
  50. }
  51. public void checkFuel(double fuelLevel) {
  52. // Write an IF statement that checks “fuelLevel”
  53. // and if that check is less than 0.08, calls “refuel()”
  54. //if(check){}
  55. }
  56. /**
  57. * Pay no attention to the code below this point.
  58. *
  59. *
  60. * instance variables
  61. * /
  62. // int x;
  63. // int tt_t;
  64. // int tt_s;
  65. // int oo1, oo2;
  66. // String ss;
  67. /**
  68. * Constructor for objects of class WriteIFs
  69. */
  70. // public WriteIFs()
  71. // {
  72. // initialise instance variables
  73. // x = 0;
  74. // tt_t = 0;
  75. // tt_s = 1;
  76. // ss = "";
  77. // oo1 = 61;
  78. // oo2 = 49;
  79. // }
  80. // associated routines
  81. public boolean isAlive(boolean p) {
  82. return !p;
  83. }
  84. private int tempurature(int t) {
  85. return t+2;
  86. }
  87. private void heatOn() {
  88. this.ss = "heating";
  89. }
  90. private void coolOn() {
  91. this.ss = "cooling";
  92. }
  93. private int insideTemp() {
  94. return oo1;
  95. }
  96. private int outsideTemp() {
  97. return oo2;
  98. }
  99. private void startAFire(Object o) {
  100. this.tt_s = 213;
  101. }
  102. private void refuel() {
  103. this.x = 99;
  104. }
  105. private void displayGameOver(boolean b) {
  106. this.ss = "Game Over!";
  107. }
  108. }