about summary refs log tree commit diff
path: root/usth/ICT2.2/labwork/3/Java/Cow.java
diff options
context:
space:
mode:
Diffstat (limited to 'usth/ICT2.2/labwork/3/Java/Cow.java')
-rw-r--r--usth/ICT2.2/labwork/3/Java/Cow.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/usth/ICT2.2/labwork/3/Java/Cow.java b/usth/ICT2.2/labwork/3/Java/Cow.java
new file mode 100644
index 0000000..36a1051
--- /dev/null
+++ b/usth/ICT2.2/labwork/3/Java/Cow.java
@@ -0,0 +1,36 @@
+public class Cow
+{
+  private String name;
+  private String breed;
+  private int age;
+
+  public Cow(String name, String breed)
+  {
+    this(name, breed, 0);
+  }
+
+  public Cow(String name, String breed, int age)
+  {
+    this.name = name;
+    this.breed = breed;
+    setAge(age);
+  }
+
+  public static void moo()
+  {
+    System.out.println("Moo...!");
+  }
+
+  public int getAge()
+  {
+    return age;
+  }
+
+  public void setAge(int age)
+  {
+    if (age < 0)
+      throw new IllegalArgumentException(
+        "age must be nonnegative, instead got " + age);
+    this.age = age;
+  }
+}