-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathGame.java
More file actions
47 lines (37 loc) · 1014 Bytes
/
Game.java
File metadata and controls
47 lines (37 loc) · 1014 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
37
38
39
40
41
42
43
44
45
46
47
import java.util.Objects;
public class Game {
private String name;
private double rating;
private int price;
public Game(String name, double rating, int price) {
this.name = name;
this.rating = rating;
this.price = price;
}
public String getName() {
return name;
}
public double getRating() {
return rating;
}
public int getPrice() {
return price;
}
@Override
public String toString() {
//TODO
return String.format("🎮 %-55s ⭐ %-4.1f/5 💵 $%-4d",
name,
rating,
price);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Game game = (Game) o;
return Double.compare(game.rating, rating) == 0 &&
Double.compare(game.price, price) == 0 &&
Objects.equals(name, game.name);
}
}