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.

WriteIFs.java 2.5KB

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