Advertisement
Crenox

Athlete Java Program

Mar 24th, 2015
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.98 KB | None | 0 0
  1. // Sammy Samkough
  2. // Athlete
  3. // Spec: Develop a customized software program that will keep track of players along with some vital stats.
  4.  
  5. public class Athlete
  6. {
  7. private String name;
  8. private int age;
  9. private double salary;
  10. private String team;
  11.  
  12. // constructors
  13. public Athlete()
  14. {
  15. name = "";
  16. age = 0;
  17. salary = 0.0;
  18. team = "";
  19. }
  20.  
  21. public Athlete(String aName, int aAge, double aSalary, String aTeam)
  22. {
  23. name = aName;
  24. age = aAge;
  25. salary = aSalary;
  26. team = aTeam;
  27. }
  28.  
  29. // accessor and modifier methods (get & sets)
  30. public String getName()
  31. {
  32. return name;
  33. }
  34.  
  35. public int getAge()
  36. {
  37. return age;
  38. }
  39.  
  40. public double getSalary()
  41. {
  42. return salary;
  43. }
  44.  
  45. public String getTeam()
  46. {
  47. return team;
  48. }
  49.  
  50. public void setName(String aName)
  51. {
  52. name = aName;
  53. }
  54.  
  55. public void setAge(int aAge)
  56. {
  57. age = aAge;
  58. }
  59.  
  60. public void setSalary(double aSalary)
  61. {
  62. salary = aSalary;
  63. }
  64.  
  65. public void setTeam(String aTeam)
  66. {
  67. team = aTeam;
  68. }
  69.  
  70. public String toString()
  71. {
  72. String data = new String();
  73. data = "Name: " + name + "\tAge: " + age + "\t\tSalary: $" + salary + "\tTeam: " + team + "\t\n";
  74. return data;
  75. }
  76. }
  77.  
  78.  
  79. -------------------------------------------------------------------------------------------------------------------------------
  80. // Sammy Samkough
  81. // Athlete
  82. // Spec: Develop a customized software program that will keep track of players along with some vital stats.
  83.  
  84. public class HockeyPlayer extends Athlete
  85. {
  86. private String name;
  87. private int age;
  88. private double salary;
  89. private int goal;
  90. private int penalty;
  91. private int assist;
  92. private int fight;
  93.  
  94. // constructors
  95. public HockeyPlayer()
  96. {
  97. super();
  98. goal = 0;
  99. penalty = 0;
  100. assist = 0;
  101. fight = 0;
  102. }
  103.  
  104. public HockeyPlayer(String aName, int aAge, String aTeam, double aSalary, int aGoal, int aPenalty, int aAssist, int aFight)
  105. {
  106. super(aName, aAge, aSalary, aTeam);
  107. goal = aGoal;
  108. penalty = aPenalty;
  109. assist = aAssist;
  110. fight = aFight;
  111. }
  112.  
  113. // accessor and modifier methods (get & sets)
  114. public int getGoal()
  115. {
  116. return goal;
  117. }
  118.  
  119. public int getPenalty()
  120. {
  121. return penalty;
  122. }
  123.  
  124. public int getAssist()
  125. {
  126. return assist;
  127. }
  128.  
  129. public int getFight()
  130. {
  131. return fight;
  132. }
  133.  
  134. public void setGoal(int aGoal)
  135. {
  136. goal = aGoal;
  137. }
  138.  
  139. public void setPenalty(int aPenalty)
  140. {
  141. penalty = aPenalty;
  142. }
  143.  
  144. public void setAssist(int aAssist)
  145. {
  146. assist = aAssist;
  147. }
  148.  
  149. public void setFight(int aFight)
  150. {
  151. fight = aFight;
  152. }
  153.  
  154. public String toString()
  155. {
  156. String result = super.toString();
  157.  
  158. result += "Goal(s): " + goal + "\tPenalty(s): " + penalty + "\tAssist(s): " + assist + "\tFight(s): " + fight +
  159. "\t\n================================================================================";
  160.  
  161. return result;
  162. }
  163. }
  164. -------------------------------------------------------------------------------------------------------------------------------
  165. // Sammy Samkough
  166. // Athlete
  167. // Spec: Develop a customized software program that will keep track of players along with some vital stats.
  168.  
  169. public class BaseballPlayer extends Athlete
  170. {
  171. private String name;
  172. private int age;
  173. private double salary;
  174. private int homerun;
  175. private int rbi; // run batted in
  176. private double ba; // batting average
  177. private int strike;
  178.  
  179. // constructors
  180. public BaseballPlayer()
  181. {
  182. super();
  183. homerun = 0;
  184. rbi = 0;
  185. ba = 0;
  186. strike = 0;
  187. }
  188.  
  189. public BaseballPlayer(String aName, int aAge, double aSalary, String aTeam, int aHomerun, int aRbi, double aBa, int aStrike)
  190. {
  191. super(aName, aAge, aSalary, aTeam);
  192. homerun = aHomerun;
  193. rbi = aRbi;
  194. ba = aBa;
  195. strike = aStrike;
  196. }
  197.  
  198. // accessor and modifier methods (get & sets)
  199. public int getHomerun()
  200. {
  201. return homerun;
  202. }
  203.  
  204. public int getRbi()
  205. {
  206. return rbi;
  207. }
  208.  
  209. public double getBa()
  210. {
  211. return ba;
  212. }
  213.  
  214. public int getStrike()
  215. {
  216. return strike;
  217. }
  218.  
  219. public void setHomerun(int aHomerun)
  220. {
  221. homerun = aHomerun;
  222. }
  223.  
  224. public void setRbi(int aRbi)
  225. {
  226. rbi = aRbi;
  227. }
  228.  
  229. public void setBa(double aBa)
  230. {
  231. ba = aBa;
  232. }
  233.  
  234. public void setStrike(int aStrike)
  235. {
  236. strike = aStrike;
  237. }
  238.  
  239. public String toString()
  240. {
  241. String result = super.toString();
  242.  
  243. result += "Homerun(s): " + homerun + "\tRbi(s): " + rbi + "\tBatting Average: " + ba + "\tStrike(s): " + strike +
  244. "\t\n================================================================================";
  245.  
  246. return result;
  247. }
  248. }
  249. -------------------------------------------------------------------------------------------------------------------------------
  250. // Sammy Samkough
  251. // Athlete
  252. // Spec: Develop a customized software program that will keep track of players along with some vital stats.
  253.  
  254. public class FootballPlayer extends Athlete
  255. {
  256. private String name;
  257. private int age;
  258. private double salary;
  259. private int touchdown;
  260. private int pass;
  261. private int receive; // throw is a keyword so we can't use it as a variable name
  262.  
  263. // constructors
  264. public FootballPlayer()
  265. {
  266. super();
  267. touchdown = 0;
  268. pass = 0;
  269. receive = 0;
  270. }
  271.  
  272. public FootballPlayer(String aName, int aAge, double aSalary, String aTeam, int aTouchdown, int aPass, int aReceive)
  273. {
  274. super(aName, aAge, aSalary, aTeam);
  275. touchdown = aTouchdown;
  276. pass = aPass;
  277. receive = aReceive;
  278. }
  279.  
  280. // accessor and modifier methods (get & sets)
  281. public int getTouchdown()
  282. {
  283. return touchdown;
  284. }
  285.  
  286. public int getPass()
  287. {
  288. return pass;
  289. }
  290.  
  291. public int getReceive()
  292. {
  293. return receive;
  294. }
  295.  
  296. public void setTouchdown(int aTouchdown)
  297. {
  298. touchdown = aTouchdown;
  299. }
  300.  
  301. public void setPass(int aPass)
  302. {
  303. pass = aPass;
  304. }
  305.  
  306. public void setReceive(int aReceive)
  307. {
  308. receive = aReceive;
  309. }
  310.  
  311. public String toString()
  312. {
  313. String result = super.toString();
  314.  
  315. result += "Touchdown(s): " + touchdown + "\tPass(s): " + pass + "\tReceive(s): " + receive +
  316. "\t\n================================================================================";
  317.  
  318. return result;
  319. }
  320. }
  321. -------------------------------------------------------------------------------------------------------------------------------
  322. // Sammy Samkough
  323. // Athlete
  324. // Spec: Develop a customized software program that will keep track of players along with some vital stats.
  325.  
  326. public class AthleteClient
  327. {
  328. public static void main(String args[])
  329. {
  330. // set name, age, salary, team
  331. HockeyPlayer hp = new HockeyPlayer(); // set goal, penalty, assist, fight
  332. FootballPlayer fp = new FootballPlayer(); // set touchdown, pass, receive
  333. BaseballPlayer bp = new BaseballPlayer(); // set homerun, rbi, ba, strike
  334.  
  335. // Hockey Player Statistics
  336. hp.setName("Zach Awari");
  337. hp.setAge(22);
  338. hp.setSalary(200000);
  339. hp.setTeam("Bandits");
  340. hp.setGoal(22);
  341. hp.setPenalty(12);
  342. hp.setAssist(18);
  343. hp.setFight(5);
  344. System.out.print(hp);
  345.  
  346. // Football Player Statistics
  347. fp.setName("Mark Shneyderman");
  348. fp.setAge(23);
  349. fp.setSalary(440000);
  350. fp.setTeam("Jokers");
  351. fp.setTouchdown(23);
  352. fp.setPass(0);
  353. fp.setReceive(33);
  354. System.out.print(fp);
  355.  
  356. // Baseball Player Statistics
  357. bp.setName("Peter Aydin");
  358. bp.setAge(24);
  359. bp.setSalary(1200000);
  360. bp.setTeam("Socks");
  361. bp.setHomerun(43);
  362. bp.setRbi(52);
  363. bp.setBa(.435);
  364. bp.setStrike(2);
  365. System.out.print(bp);
  366. }
  367. }
  368. /*
  369. Name: Zach Awari Age: 22 Salary: $200000.0 Team: Bandits
  370.  
  371. Goal(s): 22 Penalty(s): 12 Assist(s): 18 Fight(s): 5
  372. ================================================================================
  373. Name: Mark Shneyderman Age: 23 Salary: $440000.0 Team: Jokers
  374.  
  375. Touchdown(s): 23 Pass(s): 0 Receive(s): 33
  376. ================================================================================
  377. Name: Peter Aydin Age: 24 Salary: $1200000.0 Team: Socks
  378.  
  379. Homerun(s): 43 Rbi(s): 52 Batting Average: 0.435 Strike(s): 2
  380. ================================================================================
  381. Press any key to continue . . .
  382. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement