Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package FootbalTeamGenerator;
- public class Player {
- private String name;
- private int endurance;
- private int sprint;
- private int dribble;
- private int passing;
- private int shooting;
- public Player(String name, int endurance, int sprint, int dribble, int passing, int shooting) {
- this.setName(name);
- this.setEndurance(endurance);
- this.setSprint(sprint);
- this.setDribble(dribble);
- this.setPassing(passing);
- this.setShooting(shooting);
- }
- private void setName(String name) {
- Validator.nameIsValid(name);
- this.name = name;
- }
- public String getName() {
- return this.name;
- }
- private void setEndurance(int stat) {
- if (stat < 0 || stat > 100) {
- throw new IllegalArgumentException("Endurance should be between 0 and 100.");
- }
- this.endurance = stat;
- }
- private void setSprint(int stat) {
- if (stat < 0 || stat > 100) {
- throw new IllegalArgumentException("Sprint should be between 0 and 100.");
- }
- this.sprint = stat;
- }
- private void setDribble(int stat) {
- if (stat < 0 || stat > 100) {
- throw new IllegalArgumentException("Dribble should be between 0 and 100.");
- }
- this.dribble = stat;
- }
- private void setPassing(int stat) {
- if (stat < 0 || stat > 100) {
- throw new IllegalArgumentException("Passing should be between 0 and 100.");
- }
- this.passing = stat;
- }
- private void setShooting(int stat) {
- if (stat < 0 || stat > 100) {
- throw new IllegalArgumentException("Shooting should be between 0 and 100.");
- }
- this.shooting = stat;
- }
- public double overallSkillLevel() {
- return (this.endurance + this.sprint
- + this.dribble + this.passing
- + this.shooting) / 5.0;
- }
- }
Add Comment
Please, Sign In to add comment