Advertisement
Vladkoheca

Field.java

Feb 26th, 2025 (edited)
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | Source Code | 0 0
  1. public class Field {
  2.     public String name;
  3.     public double area;
  4.     public double moistureLevel;
  5.  
  6.     public Field(String name, double area, double moistureLevel) {
  7.         this.name = name;
  8.         this.area = area;
  9.         this.moistureLevel = moistureLevel;
  10.     }
  11.  
  12.     public void displayInfo() {
  13.         System.out.println("The moisture level of the field is: " + moistureLevel);
  14.     }
  15.  
  16.     public double waterField(double waterAmount) {
  17.         return moistureLevel += waterAmount;
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement