Advertisement
mmayoub

Player, 10.07.2021

Jul 10th, 2021
1,035
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. package prj10072021;
  2.  
  3. public class Player {
  4.     private String name;
  5.     private int pos;
  6.  
  7.     public Player(String name) {
  8.         this.name = name;
  9.         this.pos = 1;
  10.         System.out.println("New player was created: " + this.name);
  11.     }
  12.  
  13.     public void move(int n) {
  14.         this.pos = this.pos + n;
  15.         System.out.println("Player " + this.name + " moved to " + this.pos);
  16.     }
  17.  
  18.     public int getPos() {
  19.         return this.pos;
  20.     }
  21.  
  22.     public String getName() {
  23.         return name;
  24.     }
  25.  
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement