Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Drone {
- public String model;
- public int altitude;
- public Drone(String model, int altitude) {
- this.model = model;
- this.altitude = altitude;
- }
- public void displayInfo() {
- System.out.println("The model of the drone is: " + model + "\nThe altitude of the drone is: " + altitude);
- }
- public void fly(int newAltitude) {
- altitude = newAltitude;
- if (altitude > 10 && altitude < 100) {
- System.out.println("The new altitude is: " + altitude + "\nsafe");
- } else {
- System.out.println("The new altitude is: " + altitude + "\ncrash");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement