Advertisement
Vladkoheca

IrrigationSystem.java

Feb 26th, 2025
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | Source Code | 0 0
  1. public class IrrigationSystem {
  2.     private String systemID;
  3.     private double waterCapacity;
  4.     private boolean isAutomated;
  5.  
  6.     public IrrigationSystem(String systemID, double waterCapacity, boolean isAutomated) {
  7.         this.systemID = systemID;
  8.         this.waterCapacity = waterCapacity;
  9.         this.isAutomated = isAutomated;
  10.     }
  11.  
  12.     public String toString() {
  13.         return "The system id is: " + systemID +
  14.                 "\nThe capacity of the water of the system is: " +
  15.                 waterCapacity + (isAutomated? "\nThe system is automated." : "\nThe system is not automated");
  16.     }
  17.  
  18.     public String Irrigate(String field, double waterAmount) {
  19.         waterCapacity += waterAmount;
  20.         return field + " has been irrigated with " + waterCapacity + " water.";
  21.     }
  22.  
  23.     public String getSystemID() {
  24.         return systemID;
  25.     }
  26.  
  27.     public void setSystemID(String systemID) {
  28.         this.systemID = systemID;
  29.     }
  30.  
  31.     public double getWaterCapacity() {
  32.         return waterCapacity;
  33.     }
  34.  
  35.     public void setWaterCapacity(int waterCapacity) {
  36.         this.waterCapacity = waterCapacity;
  37.     }
  38.  
  39.     public boolean isAutomated() {
  40.         return isAutomated;
  41.     }
  42.  
  43.     public void setAutomated(boolean automated) {
  44.         isAutomated = automated;
  45.     }
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement