KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > chemistry > Element


1 package JSci.chemistry;
2
3 /**
4 * A class representing chemical elements.
5 * To obtain an instance of Element, use the {@link PeriodicTable#getElement(String) PeriodicTable.getElement} method.
6 * @version 1.6
7 * @author Mark Hale
8 */

9 public class Element extends Object JavaDoc implements java.io.Serializable JavaDoc {
10         private String JavaDoc name;
11         private String JavaDoc symbol;
12         private int atomicNumber;
13         private int massNumber;
14         private double electronegativity;
15         private double covalentRadius;
16         private double atomicRadius;
17         private double meltingPoint;
18         private double boilingPoint;
19         private double density;
20         private double specificHeat;
21         private double electricalConductivity;
22         private double thermalConductivity;
23         /**
24         * Constructs an element.
25         * @param title name of element.
26         * @param label symbol for element.
27         */

28         public Element(String JavaDoc title,String JavaDoc label) {
29                 name=title;
30                 symbol=label;
31         }
32         /**
33         * Returns the name.
34         */

35         public String JavaDoc getName() {
36                 return name;
37         }
38         /**
39         * Returns the atomic number.
40         */

41         public int getAtomicNumber() {
42                 return atomicNumber;
43         }
44         protected void setAtomicNumber(int z) {
45                 atomicNumber=z;
46         }
47         /**
48         * Returns the mass number.
49         */

50         public int getMassNumber() {
51                 return massNumber;
52         }
53         protected void setMassNumber(int m) {
54                 massNumber=m;
55         }
56         /**
57         * Returns the electronegativity.
58         */

59         public double getElectronegativity() {
60                 return electronegativity;
61         }
62         protected void setElectronegativity(double en) {
63                 electronegativity=en;
64         }
65         /**
66         * Returns the covalent radius.
67         */

68         public double getCovalentRadius() {
69                 return covalentRadius;
70         }
71         protected void setCovalentRadius(double covRadius) {
72                 covalentRadius=covRadius;
73         }
74         /**
75         * Returns the atomic radius.
76         */

77         public double getAtomicRadius() {
78                 return atomicRadius;
79         }
80         protected void setAtomicRadius(double atomRadius) {
81                 atomicRadius=atomRadius;
82         }
83         /**
84         * Returns the melting point (K).
85         */

86         public double getMeltingPoint() {
87                 return meltingPoint;
88         }
89         protected void setMeltingPoint(double melt) {
90                 meltingPoint=melt;
91         }
92         /**
93         * Returns the boiling point (K).
94         */

95         public double getBoilingPoint() {
96                 return boilingPoint;
97         }
98         protected void setBoilingPoint(double boil) {
99                 boilingPoint=boil;
100         }
101         /**
102         * Returns the density (293K).
103         */

104         public double getDensity() {
105                 return density;
106         }
107         protected void setDensity(double rho) {
108                 density=rho;
109         }
110         /**
111         * Returns the specific heat.
112         */

113         public double getSpecificHeat() {
114                 return specificHeat;
115         }
116         protected void setSpecificHeat(double heat) {
117                 specificHeat=heat;
118         }
119         /**
120         * Returns the electrical conductivity.
121         */

122         public double getElectricalConductivity() {
123                 return electricalConductivity;
124         }
125         protected void setElectricalConductivity(double elect) {
126                 electricalConductivity=elect;
127         }
128         /**
129         * Returns the thermal conductivity.
130         */

131         public double getThermalConductivity() {
132                 return thermalConductivity;
133         }
134         protected void setThermalConductivity(double therm) {
135                 thermalConductivity=therm;
136         }
137         /**
138         * Compares two elements for equality.
139         * @param e an element.
140         */

141         public boolean equals(Object JavaDoc e) {
142                 return (e!=null) && (e instanceof Element) &&
143                         (atomicNumber==((Element)e).atomicNumber) &&
144                         (massNumber==((Element)e).massNumber);
145         }
146     public int hashCode() {
147         return 37*(37*(37*17+atomicNumber)+massNumber);
148     }
149         /**
150         * Returns the chemical symbol.
151         */

152         public String JavaDoc toString() {
153                 return symbol;
154         }
155 }
156
157
Popular Tags