-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoldfish.java
28 lines (18 loc) · 865 Bytes
/
Goldfish.java
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
package com.skyroute66.petprofilersolution;
// Task 5: Step 1: make Goldfish a descendent of Pet
public class Goldfish extends Pet {
// constructor
// Task 5: Step 2: pass 2 parameters someName (String) and someAge (int) to
// the constructor of the ancestor class
public Goldfish(String someName, int someAge) {
super(someName, someAge);
}
// methods
// Task 5: Step 4:
// override the method selfDescribe()
// return a string like this WITHOUT calling the ancestor's method:
// "Hello, my name is <name>. I am a goldfish and I am <age> year(s) old. I swim around and nap all day!"
@Override public String selfDescribe() {
return "Hello, my name is " + name + ". I am a goldfish and I am " + age + " year(s) old. I swim around and nap all day!";
}
}