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

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