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

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