Advertisement
Vladkoheca

Drone.java

Nov 29th, 2024
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | Source Code | 0 0
  1. public class Drone {
  2.     public String model;
  3.     public int altitude;
  4.  
  5.     public Drone(String model, int altitude) {
  6.         this.model = model;
  7.         this.altitude = altitude;
  8.     }
  9.  
  10.     public void displayInfo() {
  11.         System.out.println("The model of the drone is: " + model + "\nThe altitude of the drone is: " + altitude);
  12.     }
  13.     public void fly(int newAltitude) {
  14.         altitude = newAltitude;
  15.         if (altitude > 10 && altitude < 100) {
  16.             System.out.println("The new altitude is: " + altitude + "\nsafe");
  17.         } else {
  18.             System.out.println("The new altitude is: " + altitude + "\ncrash");
  19.         }
  20.     }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement