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.

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