-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlayer.java
54 lines (44 loc) · 1.15 KB
/
Player.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package entity;
import java.util.Scanner;
public class Player {
private String userName;//demo 中通过ran的随机数生成名字,好改。
private int score = 0;
private int mistake = 0;
Scanner sc = new Scanner(System.in);
/**
* 通过特定名字初始化一个玩家对象。
* @param userName 玩家的名字
*/
public Player(String userName){
this.userName = userName;
}
/**z
* 通过默认名字初始化一个玩家对象。
这个地方好改!!!!!!!!!!!!!!!!!!!!!!!!
*/
public Player(){
System.out.print("Please fill in your name: ");
userName = sc.next();
}
/**
* 为玩家加一分。
*/
public void addScore(){
score++;
}
/**
* 为玩家扣一分。
*/
public void costScore(){
score--;
}
/**
* 为玩家增加一次失误数。
*/
public void addMistake() { mistake++; }
public int getScore(){
return score;
}
public String getUserName(){ return userName; }
public int getMistake(){ return mistake; }
}