Advertisement
Bene2468

Untitled

May 7th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.42 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) {
  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.     }
  29.    
  30.     // id
  31.     public int getId() {
  32.         return id;
  33.     }
  34.     public void setId (int id) {
  35.         this.id = id;
  36.     }
  37.    
  38.     // firstName
  39.     public String getFirstName() {
  40.         return firstName;
  41.     }
  42.     public void setFirstName(String firstName) {
  43.         this.firstName = firstName;
  44.     }
  45.     public void setLastName(String lastName) { // lastName
  46.         this.lastName = lastName;
  47.     }
  48.     public void setMail (String mail) { // mail
  49.         this.mail = mail;
  50.     }
  51.     public void setStreet(String street) {  // street
  52.         this.street = street;
  53.     }
  54.     public void setZip (String zip) {   // zip
  55.         this.zip = zip;
  56.     }
  57.     public void setDob (String dob) {   // dob
  58.         this.dob = dob;
  59.     }
  60.     public void setCpr(String cpr) {    // cpr
  61.         this.cpr = cpr;
  62.     }
  63.     public void setPhone(String phone) { // phone
  64.         this.phone = phone;
  65.     }
  66.  
  67.     public String getUserName() {   // userName
  68.         return userName = firstName.charAt(0) + lastName.substring(0, 3);
  69.     }
  70.     public void setUserName() {
  71.         this.userName = firstName.charAt(0) + lastName.substring(0, 3);
  72.     }
  73.     public void setUserName(String userName) { // to read from file with arg
  74.         this.userName = userName;
  75.     }
  76.  
  77.     public String getPassword() {   // password
  78.         return password = lastName.substring(0, 3) + cpr.substring(7);
  79.     }
  80.     public void setPassword() {
  81.         this.password = lastName.substring(0, 3) + cpr.substring(7);
  82.     }
  83.     public void setPassword(String password) {
  84.         this.password = password;
  85.     }
  86.    
  87.     @Override
  88.     public String toString(){
  89.         return (id + ";" + lastName + ";" + firstName + ";" + mail + ";"
  90.             + street + ";" + zip + ";" + dob + ";" + phone + ";" + cpr + ";"
  91.             + getUserName() + ";" + getPassword() + ";");
  92.     }
  93.    
  94.     public void writeToFile(){
  95.         ReadAndWrite.writeDetails("customer.txt", toString());
  96.     }
  97.  
  98. }//class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement