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

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