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.

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