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