This repository was archived by the owner on Nov 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomer.java
More file actions
95 lines (83 loc) · 2.25 KB
/
Customer.java
File metadata and controls
95 lines (83 loc) · 2.25 KB
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
import java.util.*;
import java.io.*;
/**
* Write a description of class Customer here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Customer
{
// instance variables - replace the example below with your own
private String customerID;
private String surname;
private String firstName;
private String otherInitials;
private String title;
/**
* Empty Constructor for file input
*/
public Customer() {}
/**
* Manual entry constructor
*/
public Customer(String surname, String firstName, String otherInitials, String title)
{
customerID = "unknown";
this.surname = surname;
this.firstName = firstName;
this.otherInitials = otherInitials;
this.title = title;
}
/**
*
*/
public void printDetails()
{
System.out.println("");
System.out.printf("%-25s: %s\n", "Customer ID", customerID);
System.out.printf("%-25s: %s\n", "Surname", surname);
System.out.printf("%-25s: %s\n", "First Name", firstName);
System.out.printf("%-25s: %s\n", "Other Initials", otherInitials);
System.out.printf("%-25s: %s\n", "Title", title);
}
public void setIdIfUnknown(String newID)
{
if (customerID.equals("unknown"))
{
customerID = newID;
}
}
public void readData(Scanner fieldScanner)
{
customerID = fieldScanner.next().trim();
surname = fieldScanner.next().trim();
firstName = fieldScanner.next().trim();
otherInitials = fieldScanner.next().trim();
title = fieldScanner.next().trim();
}
public void writeData(PrintWriter pWriter)
{
pWriter.println(customerID + ", " + surname + ", " + firstName + ", " + otherInitials + ", " + title);
}
public String getCustomerID()
{
return customerID;
}
public String getSurname()
{
return surname;
}
public String getFirstName()
{
return firstName;
}
public String getOtherInitials()
{
return otherInitials;
}
public String getTitle()
{
return title;
}
}