-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimal.java
More file actions
36 lines (27 loc) · 842 Bytes
/
Animal.java
File metadata and controls
36 lines (27 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.dj;
abstract class Mammals extends Animal {
public Mammals(String type, String size, double weight) {
super(type, size, weight);
}
@Override
public void move(String speed) {
System.out.println(getExplicitType() + " ");
System.out.println(speed.equals("slow") ? "walks" : "runs");
}
public abstract void shedHAir();
}
public abstract class Animal {
protected String type;
private String size;
private double weight;
public Animal(String type, String size, double weight) {
this.type = type;
this.size = size;
this.weight = weight;
}
public abstract void move(String speed);
public abstract void makeNoise();
public final String getExplicitType(){
return getClass().getSimpleName() + " (" + type + ")";
}
}