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.4KB

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