Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package winda;
  7.  
  8. import static java.lang.Math.floor;
  9.  
  10. public class Elevator {
  11.  
  12. int floor = 0; // pietro
  13. //int choice1; // wybor windy
  14. int person = 0; // wybor osoby
  15.  
  16. public Elevator() {
  17. } //--- konstruktor po to by utworzyc obiekt windy, tak może być pusty
  18.  
  19. Doors d = new Doors(); //--- tworze sobie drzwi w windzie :)
  20.  
  21. public int getFloor(){ //----- zwraca pietro na ktorym jestes teraz, nie mozesz miec wszedzie soutów bo potem bedzie apka bez opcji soutów
  22. return floor;
  23. }
  24. //-------------------------------------
  25.  
  26. // floor = (int)(Math.random() * 10 + 1);
  27.  
  28. // System.out.println("Doors open? " + choice1);
  29. // System.out.println("Which floor are you at now (0-10) where 0 = basement: ");
  30. //choice1 = Keyboard.readInt();
  31.  
  32. //--------------------------------------
  33.  
  34. // przywolanie windy inaczej nizej
  35. public void callElevator(int choice1) {
  36. if (floor == choice1) {
  37. System.out.println("Enter the elevator");
  38. } else if (floor > choice1) {
  39. move(choice1);
  40. } else if (floor < choice1) {
  41. move(choice1);
  42. }
  43. }
  44.  
  45.  
  46. /////-------------------------------------------
  47.  
  48.  
  49. //-----------!!!!!!!!!!!----------------------- zmienilem te dwa w 1 funkcje o nazwie move jest ona nizej
  50. // public void ElevatorUp(int choice1) { //czlowiek w windzie wybiera gdzie chce jechac
  51. // System.out.println("The elevator is on it's way up...");
  52. // for (person = choice1; choice1 > floor; floor++) {
  53. // System.out.println(floor);
  54. // }
  55. // System.out.println("The elevator has arrived on floor "+choice1);
  56. // d.Open();
  57. // }
  58. //
  59. // public void ElevatorDown(int choice1) { // czlowiek w windzie wybiera ze chce jechac w dol
  60. // System.out.println("The elevator is on it's way down...");
  61. // for (person = choice1; choice1 < floor; floor--) {
  62. // System.out.println(floor);
  63. // }
  64. // System.out.println("The elevator has arrived on floor "+choice1);
  65. // d.Open();
  66. // }---------!!!!!!!----------- zmienilem te dwa w 1 funkcje o nazwie move jest ona nizej
  67.  
  68. public void move(int choice1){
  69. if(choice1>floor){
  70. d.Close();
  71. System.out.println("The elevator is on it's way up...");
  72. for (person = choice1; choice1 > floor; floor++) {
  73. System.out.println(floor);
  74. }
  75. System.out.println("The elevator has arrived on floor "+choice1);
  76. d.Open();
  77. System.out.println("Koniec polecenia \n");
  78. }
  79. else if(choice1<floor){
  80. d.Close();
  81. System.out.println("The elevator is on it's way down...");
  82. for (person = choice1; choice1 < floor; floor--) {
  83. System.out.println(floor);
  84. }
  85. System.out.println("The elevator has arrived on floor "+choice1);
  86. d.Open();
  87. System.out.println("Koniec polecenia \n");
  88. }
  89. else if(choice1 == floor){
  90. System.out.println("Elevator is on this floor already");
  91. }
  92. }
  93. }
  94.  
  95. // System.out.println ( ---------------------------- same shit as Enter Elevator
  96. // "To which floor would you want to go (0-10) where 0 = basement");
  97. // choice1 = Keyboard.readInt();
  98. //
  99. // if(floor > choice1)
  100. // {ElevatorDown();}
  101. //
  102. // else if(floor<choice1)
  103. // {ElevatorUp();}
  104. //}
  105. //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement