-
Notifications
You must be signed in to change notification settings - Fork 0
/
Part
127 lines (107 loc) · 2.41 KB
/
Part
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**
* This class is an object that has 4 values in it:
* name - A textual name
* number - an alphanumeric sequence that may contain hyphens
* ncage - A five character alphanumeric code for a business of the form NNNNN
* niin - a 13 digit code of the form XXXX-XX-XXX-XXXX
* @author
* @version 0.4
*/
public class Part {
//member of the class
private String Name, Number, nCage, nIin;
//default constructor
public Part(String Name, String Number, String nCage, String nIin)
{
this.Name = Name;
this.Number = Number;
this.nCage = nCage;
this.nIin = nIin;
}
//assuming all parameters but nIin is given, default is called
public Part(String Name, String Number, String nCage)
{
this(Name, Number, nCage, null);
}
//assuming all parameters but nIin and nCage is given, default is called
public Part(String Name, String Number)
{
this(Name, Number, null, null);
}
//assuming only name is given, default is called
public Part(String Name)
{
this(Name, null, null, null);
}
//assuming NO parameters is given, default is called
public Part()
{
this(null, null, null, null);
}
//formatting toString method
@Override
public String toString()
{
return String.format("PART:%s,PIN:%s,NCAGE:%s,NIIN:%s", Name, Number, nCage, nIin);
}
//compares two objects of parts. two parts are only equal if they have the same number
//ncage and niin
public boolean equals(Object otherPart) {
boolean result = false;
if (otherPart instanceof Part) {
Part other = (Part)otherPart;
if (
this.Number.equals(other.Number) &&
this.nCage.equals(other.nCage) &&
this.nIin.equals(other.nIin)
)
result = true;
}
return ( result );
}
//Accessor(getter) functions */
//gets name
public String getName()
{
return Name;
}
//gets number
public String getNumber()
{
return Number;
}
//gets five character alphanumeric code
public String getnCage()
{
return nCage;
}
//gets a 13 digit code
public String getnIin()
{
return nIin;
}
//Mutator(setter functions)
//method to set name
public void setName(String nameStr)
{
this.Name = nameStr;
}
//method to set Number
public void setNumber(String num)
{
this.Number = num;
}
//method to set cage
public void setnCage(String cage)
{
this.nCage = cage;
}
//method to set niin
public void setnIin(String niin)
{
this.nIin = niin;
}
public void fail() {
// TODO Auto-generated method stub
}
}