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.

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