I keep getting the following error when compiling the following code and can't find the source "Elevator.java uses or overrides a deprecated API" "Note: Recompile with -Xlint:deprecation for details". I believe it is because I am using an outdated input but can't for the life of me find where. Im sure it is obvious. Can anyone nudge me in the correct direction? Thank you in advance
private final int floors; // floors cannot be changes once set
private int currentFloor;
public Elevator(int floors) {
this.floors = floors;
currentFloor = 1;
}
// default constructor
public Elevator() {
floors = 5;
currentFloor = 1;
}
public int getCurrentFloor() {
return currentFloor;
}
public void up(int floor) {
if (floor >= floors) {
System.out.println("Floor entered #"+floor);
System.out.println("Sorry - Invalid floor entered. Building has only " + floors + " floors.");
} else if (floor < currentFloor) {
System.out.println("Floor entered #"+floor);
System.out.println("Sorry - Elevator currently at floor #" + floors);
} else if (floor < 1) {
System.out.println("Floor entered #"+floor);
System.out.println("Sorry - Invalid floor number entered.");
} else if (floor == currentFloor) {
System.out.println("Elevator waiting at floor #" + floor);
} else {
for (int f = currentFloor; f <= floor; f++) {
System.out.println("Elevator ascending... Current floor #" + f);
}
currentFloor = floor;
System.out.println("Elevator currently at floor #"+currentFloor+". Please get inside.");
}
}
public void down(int floor) {
if (floor >= floors) {
System.out.println("Floor entered #"+floor);
System.out.println("Sorry - Invalid floor entered. Building has only " + floors + " floors.");
} else if (floor > currentFloor) {
System.out.println("Sorry - Elevator currently at floor #" + floors);
} else if (floor < 1) {
System.out.println("Floor entered #"+floor);
System.out.println("Sorry - Invalid floor number entered.");
} else if (floor == currentFloor) {
System.out.println("Elevator waiting at floor #" + floor);
} else {
for (int f = currentFloor; f >= floor; f--) {
System.out.println("Elevator descending... Current floor #" + f);
}
currentFloor = floor;
System.out.println("Elevator currently at floor #"+currentFloor+". Please get inside.");
}
}
protected void finalize() throws Throwable {
currentFloor = 1;
System.out.println("Elevator ending: elevator returned to the first floor.");
}
public static void main(String[] args) {
Elevator calgaryTower = new Elevator(20);
System.out.println("calgaryTower.getCurrentFloor() = " + calgaryTower.getCurrentFloor());
System.out.println("Pressed 6 ...");
calgaryTower.up(6);
System.out.println("Pressed 4 ...");
calgaryTower.down(4);
calgaryTower.up(4);
calgaryTower.down(4);
calgaryTower.up(30);
calgaryTower.down(-9);
calgaryTower = null; // variable set to null
calgaryTower = new Elevator(); // variable set to a new object using default constructor
}
}```