Skip to content

Commit 3588202

Browse files
Finished Programming Exercise 7
1 parent f711abd commit 3588202

File tree

4 files changed

+132
-0
lines changed

4 files changed

+132
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* This program was written by Kyle Martin on 7/10/2021 for Java Programming Principles 2 during Summer Session 2
3+
* at Southwestern College, Kansas.
4+
*
5+
* IMPORTANT: Normally I would not place a bunch of comments in my code describing what my code is doing as I like to
6+
* have code that is written in a manner to be understandable while reading it. Though, do to the grading rubric I will
7+
* explain my code.
8+
*
9+
* This program was created to print customer data.
10+
* See Chapter 10 Programming Exercise 7.
11+
*/
12+
13+
package ExerciseSeven;
14+
15+
public class Customer extends Person {
16+
private int customerNumber;
17+
private Boolean mailingList;
18+
19+
public int getCustomerNumber() {
20+
return customerNumber;
21+
}
22+
23+
public void setCustomerNumber(int customerNumber) {
24+
this.customerNumber = customerNumber;
25+
}
26+
27+
public Boolean getMailingList() {
28+
return mailingList;
29+
}
30+
31+
public void setMailingList(Boolean mailingList) {
32+
this.mailingList = mailingList;
33+
}
34+
35+
public Customer(String name, String address, String phoneNumber, int customerNumber, Boolean mailingList) {
36+
super(name, address, phoneNumber);
37+
this.customerNumber = customerNumber;
38+
this.mailingList = mailingList;
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* This program was written by Kyle Martin on 7/10/2021 for Java Programming Principles 2 during Summer Session 2
3+
* at Southwestern College, Kansas.
4+
*
5+
* IMPORTANT: Normally I would not place a bunch of comments in my code describing what my code is doing as I like to
6+
* have code that is written in a manner to be understandable while reading it. Though, do to the grading rubric I will
7+
* explain my code.
8+
*
9+
* This program was created to print customer data.
10+
* See Chapter 10 Programming Exercise 7.
11+
*/
12+
13+
package ExerciseSeven;
14+
15+
public class ExerciseSevenDemo {
16+
public static void main(String[] args) {
17+
Customer currentCustomer = new Customer("Karen", "123 Lane St. City, ST 12345",
18+
"12345678910", 1, true);
19+
20+
String desiredMailingList;
21+
if (currentCustomer.getMailingList()) {
22+
desiredMailingList = "Yes";
23+
} else {
24+
desiredMailingList = "No";
25+
}
26+
27+
System.out.println("Current Customer Data:");
28+
System.out.println("Customer Name: \t" + currentCustomer.getName());
29+
System.out.println("Customer Address: \t" + currentCustomer.getAddress());
30+
System.out.println("Customer Phone Number: \t" + currentCustomer.getPhoneNumber());
31+
System.out.println("Customer Number: \t" + currentCustomer.getCustomerNumber());
32+
System.out.println("Wants to be on mailing list: \t" + desiredMailingList);
33+
}
34+
}
28.3 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* This program was written by Kyle Martin on 7/10/2021 for Java Programming Principles 2 during Summer Session 2
3+
* at Southwestern College, Kansas.
4+
*
5+
* IMPORTANT: Normally I would not place a bunch of comments in my code describing what my code is doing as I like to
6+
* have code that is written in a manner to be understandable while reading it. Though, do to the grading rubric I will
7+
* explain my code.
8+
*
9+
* This program was created to print customer data.
10+
* See Chapter 10 Programming Exercise 7.
11+
*/
12+
13+
package ExerciseSeven;
14+
15+
public class Person {
16+
private String name;
17+
private String address;
18+
private String phoneNumber;
19+
20+
// Getters
21+
public String getName() {
22+
return name;
23+
}
24+
25+
public String getAddress() {
26+
return address;
27+
}
28+
29+
public String getPhoneNumber() {
30+
return phoneNumber;
31+
}
32+
33+
// Setters
34+
public void setName(String name) {
35+
this.name = name;
36+
}
37+
38+
public void setAddress(String address) {
39+
this.address = address;
40+
}
41+
42+
public void setPhoneNumber(String phoneNumber) {
43+
this.phoneNumber = phoneNumber;
44+
}
45+
46+
// Constructor
47+
public Person(String name, String address, String phoneNumber) {
48+
this.name = name;
49+
this.address = address;
50+
this.phoneNumber = phoneNumber;
51+
}
52+
53+
public Person(String name) {
54+
this.name = name;
55+
this.address = "";
56+
this.phoneNumber = "";
57+
}
58+
}

0 commit comments

Comments
 (0)