Skip to content

Commit 84383c7

Browse files
committed
final(?) version of lab3
1 parent 941d7b5 commit 84383c7

File tree

16 files changed

+112
-54
lines changed

16 files changed

+112
-54
lines changed
Binary file not shown.
Binary file not shown.
79 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

programming/sem1/lab3/src/Character/BasicCharacter.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import src.Clothes.Cloth;
44
import src.IBasicObj;
5+
import src.Locations.Location;
6+
7+
import java.util.Objects;
58

69
public abstract class BasicCharacter implements IBasicObj {
710
private final String name;
@@ -34,7 +37,32 @@ public BasicCharacter(String name) {
3437

3538
public void throwPotatoes(){
3639
this.setPotatoes(0);
37-
System.out.println(this.getName() + " швырнул картофель в сторону.");
40+
System.out.print(this.getName() + " швырнул картофель в сторону. ");
41+
}
42+
43+
@Override
44+
public int hashCode() {
45+
return Objects.hash(this.getName(), this.getEnergy(), this.getPotatoes());
3846
}
3947

48+
@Override
49+
public boolean equals(Object o) {
50+
if (this == o) return true;
51+
if (o == null || getClass() != o.getClass()) return false;
52+
BasicCharacter character = (BasicCharacter) o;
53+
return this.getName().equals(character.getName()) &&
54+
this.getCloth().equals(character.getCloth()) &&
55+
this.getEnergy() == character.getEnergy() &&
56+
this.getPotatoes() == character.getPotatoes();
57+
}
58+
59+
@Override
60+
public String toString() {
61+
return "Character{" +
62+
"name=" + this.getName() +
63+
", energy=" + this.getEnergy() +
64+
", potatoes=" + this.getPotatoes() +
65+
", cloth=" + this.getCloth() +
66+
'}';
67+
}
4068
}
Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
11
package src.Clothes;
22

3-
/*import src.IBasicObj;
4-
5-
public abstract class Cloth implements IBasicObj {
6-
private final int id;
7-
private final String name;
8-
private int potatoesCount;
9-
private final int stepIncriment;
10-
11-
public Cloth(String name, int stepIncriment) {
12-
this.name = name;
13-
this.stepIncriment = stepIncriment;
14-
this.id = 0;
15-
}
16-
17-
public void makeStep(){
18-
potatoesCount -= stepIncriment;
19-
}
20-
21-
public String getName(){ return this.name; }
22-
public int getId(){ return this.id; }
23-
}*/
24-
253
public record Cloth(String name, int stepIncriment) { }

0 commit comments

Comments
 (0)