H:\CSC120\Java\lec11\src\BaseballHitter.java
 1 /*
 2  * To change this license header, choose License Headers in Project Properties.
 3  * To change this template file, choose Tools | Templates
 4  * and open the template in the editor.
 5  */
 6 
 7 /**
 8  *
 9  * @author CINDRICBB
10  */
11 public class BaseballHitter {
12     
13     private String name;
14     private Integer atBats, hits, rbis;
15     private Boolean isSwitchHitter;
16     
17     
18     public BaseballHitter( String n, Integer ab, Integer h, Integer r, Boolean sh ) {
19         name = n;
20         atBats = ab;
21         hits = h;
22         rbis = r;
23         isSwitchHitter = sh;
24     } // end of constructor
25     
26     
27     // getters
28     
29     public String getName() {
30         return name;
31     }  // end of getName 
32     
33     public Integer getAtBats() {
34         return atBats;
35     }  // end of getAtBats
36     
37     public Integer getHits() {
38         return hits;
39     }  // end of getHits
40     
41     public Integer getRBIs() {
42         return rbis;
43     }  // end of getRBIs
44     
45     public Boolean getIsSwitchHitter() {
46         return isSwitchHitter;
47     }  // end of getIsSwitchHitter 
48     
49     
50     // setters
51     
52     public void setName( String n ) {
53         name = n;
54     } // end of setName
55     
56     public void setAtBats( Integer ab ) {
57         atBats = ab;
58     } // end of setAtBats
59     
60     public void setHits( Integer h ) {
61         hits = h;
62     } // end of setHits
63     
64     public void setRBIs( Integer r ) {
65         rbis = r;
66     } // end of setRBIs
67     
68     public void setIsSwitchHitter( Boolean sh ) {
69         isSwitchHitter = 
70                 sh;
71     } // end of setIsSwitchHitter
72     
73 
74     // other methods...
75     
76     public String toString() {
77         return name + " has " + hits + " hits in " 
78                 + atBats + " atBats, and has driven in " + rbis
79                 + " runs. It is "
80                 + isSwitchHitter + " that " + name + " is a switch-hitter";
81     } // end of toString
82      
83 
84     public Double calculateBattingAvg() {
85         return 1.0 * hits / atBats;
86     } // end of calculateBattingAvg
87     
88 
89 } // end of class BaseballHitter
90 
91 
92 
93 
94 
95 
96 
97 
98