-
Notifications
You must be signed in to change notification settings - Fork 0
/
SuperClassAndSubClass.java
101 lines (69 loc) · 1.87 KB
/
SuperClassAndSubClass.java
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
import java.util.Scanner;
public class SuperClassAndSubClass {
public static void main(String[] args) {
APerson p1 = new APerson();
APerson p2 = new APerson("Robert", "Resendez", "888-111-3333", 21, "email@email.com" );
System.out.println("p1 age: " + p1.getAge());
System.out.println(p2);
}
}
class APerson implements Driver {
private String fName;
private String lName;
private String eMail;
private String socialSecurity;
private int age;
// basic constructor empty
public APerson() {
}
public String howToDrive() {
return "Drives Carefully";
}
// designated constructor
public APerson(String fN, String lName, String ss, int age, String e) {
fName = fN;
this.lName = lName;
socialSecurity = ss;
this.age = age;
eMail = e;
}
public void setfName(String fName) {
fName = fName;
}
public void setLname(String lname) {
lname = lname;
}
public void seteMail(String email) {
eMail = email;
}
public void setSSN(String ssn) {
socialSecurity = ssn;
}
public void setAge (int a) {
if (a >= 0)
age = a;
else
System.out.println("age can't be negitive");
}
public String getfirstName() {
return fName;
}
public String getLastName(){
return lName;
}
public String getEMail(){
return eMail;
}
public String getSSN(){
return socialSecurity;
}
public int getAge(){
return age;
}
public String toString(){
return "First Name: " + fName + " Last Name: " + lName + " Email Address: " + eMail + " Social Security # " + socialSecurity + " Age: " + age + " Driving Status: " + howToDrive();
}
}
interface Driver {
public String howToDrive();
}