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

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