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.

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