Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 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. import java.util.Scanner;
  10.  
  11. public class Elevator {
  12.  
  13. int floor = 0; // pietro
  14. //int choice1; // wybor windy
  15. int person = 0; // wybor osoby
  16.  
  17. public Elevator() {
  18. } //--- konstruktor po to by utworzyc obiekt windy, tak może być pusty
  19.  
  20. Doors d = new Doors(); //--- tworze sobie drzwi w windzie :)
  21.  
  22. public int getFloor() { //----- zwraca pietro na ktorym jestes teraz, nie mozesz miec wszedzie soutów bo potem bedzie apka bez opcji soutów
  23. return floor;
  24. }
  25. //-------------------------------------
  26.  
  27. // floor = (int)(Math.random() * 10 + 1);
  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. // przywolanie windy inaczej nizej
  33. public void move(int choice1) {
  34. if (choice1 > floor) {
  35. d.Close();
  36. System.out.println("The elevator is on it's way up...");
  37. for (person = choice1; choice1 > floor; floor++) {
  38. System.out.println(floor);
  39. }
  40. System.out.println("The elevator has arrived on floor " + choice1);
  41. d.Open();
  42. System.out.println("Koniec polecenia \n");
  43. } else if (choice1 < floor) {
  44. d.Close();
  45. System.out.println("The elevator is on it's way down...");
  46. for (person = choice1; choice1 < floor; floor--) {
  47. System.out.println(floor);
  48. }
  49. System.out.println("The elevator has arrived on floor " + choice1);
  50. d.Open();
  51. System.out.println("Koniec polecenia \n");
  52. } else if (choice1 == floor) {
  53. System.out.println("Elevator is on this floor already");
  54. }
  55. }
  56.  
  57. public void buttonOutside(int choice1) {
  58. if (floor == choice1) {
  59. System.out.println("Enter the elevator");
  60. } else if (floor > choice1) {
  61. move(choice1);
  62. } else if (floor < choice1) {
  63. move(choice1);
  64. }
  65. }
  66.  
  67. public void buttonInside() {
  68. Scanner keyboard = new Scanner(System.in);
  69. System.out.println("Where would you like to go? : ");
  70. int choice1 = keyboard.nextInt();
  71. move(choice1);
  72.  
  73. }
  74. }
  75.  
  76. /////-------------------------------------------
  77. //-----------!!!!!!!!!!!----------------------- zmienilem te dwa w 1 funkcje o nazwie move jest ona nizej
  78. // public void ElevatorUp(int choice1) { //czlowiek w windzie wybiera gdzie chce jechac
  79. // System.out.println("The elevator is on it's way up...");
  80. // for (person = choice1; choice1 > floor; floor++) {
  81. // System.out.println(floor);
  82. // }
  83. // System.out.println("The elevator has arrived on floor "+choice1);
  84. // d.Open();
  85. // }
  86. //
  87. // public void ElevatorDown(int choice1) { // czlowiek w windzie wybiera ze chce jechac w dol
  88. // System.out.println("The elevator is on it's way down...");
  89. // for (person = choice1; choice1 < floor; floor--) {
  90. // System.out.println(floor);
  91. // }
  92. // System.out.println("The elevator has arrived on floor "+choice1);
  93. // d.Open();
  94. // }---------!!!!!!!----------- zmienilem te dwa w 1 funkcje o nazwie move jest ona nizej
  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