Advertisement
Vladkoheca

IrrigationSystem.java

Feb 26th, 2025 (edited)
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | Source Code | 0 0
  1. public class IrrigationSystem {
  2.     public String systemID;
  3.     public double waterCapacity;
  4.     public 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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement