-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
90 lines (66 loc) · 1.91 KB
/
Copy pathPlayer.java
File metadata and controls
90 lines (66 loc) · 1.91 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Anthony Dike
// March 17, 2018
import java.text.MessageFormat;
public class Player {
// data fields
String first;
String last;
int height = 185;
int weight = 80;
int agility = 1;
int strength = 1;
/* constructor */
Player(){
}
String fullName(String newFirst, String newLast) {
first = newFirst;
last = newLast;
return MessageFormat.format("{0} {1}", first, last);
}
int setHeight(int newHeight){
height = newHeight;
return height;
}
int setWeight(int newWeight){
weight = newWeight;
return weight;
}
int setAgility(int newAgility){
agility = newAgility;
return agility;
}
int setStrength(int newStrength){
strength = newStrength;
return strength;
}
int offRating(int dribble, int jumpshot, int layup, int assist) {
int totalOffRating = dribble + jumpshot + layup + assist;
int avgOffRating = (int)((totalOffRating / 4) + ((totalOffRating % 4) / 4));
return avgOffRating;
}
int defRating(int steal, int block){
int totalDefRating = steal + block;
int avgDefRating = (int)((totalDefRating / 2) + ((totalDefRating % 2) / 2));
return avgDefRating;
}
//TEST: successful
public static void main(String[] args){
// Object aka instance
Player player1 = new Player();
player1.setHeight(205);
player1.setWeight(100);
player1.setAgility(6);
player1.setStrength(8);
System.out.println();
System.out.println("\nHi, my name is " + player1.fullName("Tony", "Douglass") + ".");
System.out.println("I weigh " + player1.weight + "kg.");
System.out.println("I am " + player1.height + "cm tall.");
System.out.println("My agility rating is " + player1.agility);
System.out.println("My strength rating is " + player1.strength);
System.out.println("And my offensive rating (1 - 10) is " +
player1.offRating(6, 7, 8, 9) + ".");
System.out.println("And my defensive rating (1 - 10) is " +
player1.defRating(6, 8) + ".\n");
System.out.println();
}
}