forked from Apress/functional-interfaces-in-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPet.java
More file actions
32 lines (31 loc) · 687 Bytes
/
Pet.java
File metadata and controls
32 lines (31 loc) · 687 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
package chapter1;
import java.util.*;
public class Pet
{
String name;
String animal;
String breed;
String color;
double price;
static List<Pet> pets = new ArrayList<>();
public Pet(String n, String a, String b, String c, double p)
{
name = n;
animal = a;
breed = b;
color = c;
price = p;
}
@Override
public String toString()
{
return name + ":" + " a " + color + " " + breed
+ " " + animal + " for $" + price;
}
@Override
public boolean equals(Object o)
{
Pet p = (Pet)o;
return animal.equals(p.animal) && breed.equals(p.breed);
}
}