Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.regex.Pattern;
- import java.util.regex.Matcher;
- public class newplayer {
- private String name;
- private int wins;
- private char symbol;
- public newplayer (String newName, String newSymbol) throws Exception{
- setName(newName);
- setSymbol(newSymbol);
- }
- public String getName() {
- return name;
- }
- public void setName(String newname) {
- name = newname;
- }
- public char getSymbol() {
- return symbol;
- }
- public void setSymbol(String newSymbol) throws Exception {
- Pattern p = Pattern.compile("(\\w)");
- Matcher m = p.matcher(newSymbol);
- if (m.find() != true) {
- throw new Exception("Please choos a single character");
- }
- symbol = newSymbol.charAt(0);
- }
- public int getWins(){
- return wins;
- }
- public void addWins() {
- wins++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement