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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. public void playerDied(boolean player1) {
  10. // Write an IF statement that checks “player1.isAlive()”
  11. // and if that’s false, calls “displayGameOver(player1)”
  12. if(!isAlive(player1)){
  13. displayGameOver(player1);
  14. }
  15. }
  16. public String thermoSTAT(int room) {
  17. // Write an IF statement that checks the
  18. // “temperature(room)” and if that check is less than 70,
  19. // calls “heatOn()” else calls “coolOn()”
  20. String fin = "";
  21. if(tempurature(room) < 70){
  22. heatOn();
  23. } else{
  24. coolOn();
  25. }
  26. return this.ss;
  27. }
  28. public void fireplaceControl(Object fireplace1) {
  29. // Write an IF statement that checks
  30. // “outsideTemp()” is less than 50
  31. // AND
  32. // “insideTemp()” is less than 62,
  33. // calls “startAFire(fireplace1)”
  34. if(outsideTemp() < 50 && insideTemp() < 62){
  35. startAFire(fireplace1);
  36. }
  37. }
  38. public void checkFuel(double fuelLevel) {
  39. // Write an IF statement that checks “fuelLevel”
  40. // and if that check is less than 0.08, calls “refuel()”
  41. if(fuelLevel < .08){
  42. refuel();
  43. }
  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. }