Guest User

Untitled

a guest
May 7th, 2017
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.97 KB | None | 0 0
  1. package Model;
  2.  
  3. import data.ReadAndWrite;
  4.  
  5. public class Customer {
  6.    
  7.     // data fields
  8.     private String firstName, lastName, mail, street, zip, dob, phone, cpr, userName, password, ccNumber, ccv, expiryDate;
  9.     private int id;
  10.     private static int count = 0;
  11.  
  12.     public Customer () { // non-arg with id increment
  13.         this.id = count++;
  14.     }
  15.    
  16.     public Customer (String firstName, String lastName, String mail, String street, String zip, String dob, String phone, String cpr, String ccNumber, String expiryDate, String ccv) {
  17.         this.id = count++;
  18.         this.firstName = firstName;
  19.         this.lastName = lastName;
  20.         this.mail = mail;
  21.         this.street = street;
  22.         this.zip = zip;
  23.         this.dob = dob;
  24.         this.phone = phone;
  25.         this.cpr = cpr;
  26.         this.getUserName();
  27.         this.getPassword();
  28.         this.ccNumber = ccNumber;
  29.         this.expiryDate = expiryDate;
  30.         this.ccv  = ccv;
  31.     }
  32.    
  33.     // id
  34.     public int getId() {
  35.         return id;
  36.     }
  37.     public void setId (int id) {
  38.         this.id = id;
  39.     }
  40.    
  41.     // firstName
  42.     public String getFirstName() {
  43.         return firstName;
  44.     }
  45.     public void setFirstName(String firstName) {
  46.         this.firstName = firstName;
  47.     }
  48.     public void setLastName(String lastName) { // lastName
  49.         this.lastName = lastName;
  50.     }
  51.     public void setMail (String mail) { // mail
  52.         this.mail = mail;
  53.     }
  54.     public void setStreet(String street) {  // street
  55.         this.street = street;
  56.     }
  57.     public void setZip (String zip) {   // zip
  58.         this.zip = zip;
  59.     }
  60.     public void setDob (String dob) {   // dob
  61.         this.dob = dob;
  62.     }
  63.     public void setCpr(String cpr) {    // cpr
  64.         this.cpr = cpr;
  65.     }
  66.     public void setPhone(String phone) { // phone
  67.         this.phone = phone;
  68.     }
  69.  
  70.     public String getUserName() {   // userName
  71.         return userName = firstName.charAt(0) + lastName.substring(0, 3);
  72.     }
  73.     public void setUserName() {
  74.         this.userName = firstName.charAt(0) + lastName.substring(0, 3);
  75.     }
  76.     public void setUserName(String userName) { // to read from file with arg
  77.         this.userName = userName;
  78.     }
  79.  
  80.     public String getPassword() {   // password
  81.         return password = lastName.substring(0, 3) + cpr.substring(7);
  82.     }
  83.     public void setPassword() {
  84.         this.password = lastName.substring(0, 3) + cpr.substring(7);
  85.     }
  86.     public void setPassword(String password) {
  87.         this.password = password;
  88.     }
  89.    
  90.     // ccNumber
  91.     public String getCcNumber() {
  92.         return ccNumber;
  93.     }
  94.     public void setCcNumber(String ccNumber) {
  95.         this.ccNumber = ccNumber;
  96.     }
  97.    
  98.     // expiryDate
  99.     public String getExpiryDate() {
  100.         return expiryDate;
  101.     }
  102.     public void setExpiryDate(String expiryDate) {
  103.         this.expiryDate = expiryDate;
  104.     }
  105.    
  106.     // ccv
  107.     public String getCcv() {
  108.         return ccv;
  109.     }
  110.     public void setCcv(String ccv) {
  111.         this.ccv = ccv;
  112.     }
  113.    
  114.     @Override
  115.     public String toString(){
  116.         return (id + ";" + lastName + ";" + firstName + ";" + mail + ";"
  117.             + street + ";" + zip + ";" + dob + ";" + phone + ";" + cpr + ";"
  118.             + getUserName() + ";" + getPassword() + ";");
  119.     }
  120.    
  121.     public void writeToFile(){
  122.         ReadAndWrite.writeDetails("customer.txt", toString());
  123.     }
  124.  
  125. }//class
Add Comment
Please, Sign In to add comment