Advertisement
Guest User

Untitled

a guest
Apr 18th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.87 KB | None | 0 0
  1. package model;
  2.  
  3. import data.FileManipulation;
  4.  
  5. public class Customer {
  6.     private String firstName;
  7.     private String lastName;
  8.     private String address;
  9.     private String email;
  10.     private String cpr;
  11.     private String username;
  12.     private String password;
  13.     private String creditCardNumber;
  14.     private String creditCardExpiration;
  15.     private String creditCardCvc;
  16.  
  17.     public Customer() {
  18.  
  19.     }
  20.  
  21.     public Customer(String myFirstName, String myLastName, String myAddress, String myEmail, String myCpr) {
  22.         firstName = myFirstName;
  23.         lastName = myLastName;
  24.         address = myAddress;
  25.         email = myEmail;
  26.         cpr = myCpr;
  27.         setUsername();
  28.         setPassword();
  29.     }
  30.  
  31.     @Override
  32.     public String toString() {
  33.         return firstName + " " + lastName;
  34.     }
  35.  
  36.     public String getFirstName() {
  37.         return firstName;
  38.     }
  39.  
  40.     // object instead of void to make it easy to read and set data for customer
  41.     public Customer setFirstName(String firstName) {
  42.         this.firstName = firstName;
  43.         return this;
  44.     }
  45.  
  46.     public String getLastName() {
  47.         return lastName;
  48.     }
  49.  
  50.     public Customer setLastName(String lastName) {
  51.         this.lastName = lastName;
  52.         return this;
  53.     }
  54.  
  55.     public String getAddress() {
  56.         return address;
  57.     }
  58.  
  59.     public Customer setAddress(String address) {
  60.         this.address = address;
  61.         return this;
  62.     }
  63.  
  64.     public String getEmail() {
  65.         return email;
  66.     }
  67.  
  68.     public Customer setEmail(String email) {
  69.         this.email = email;
  70.         return this;
  71.     }
  72.  
  73.     public String getCpr() {
  74.         return cpr;
  75.     }
  76.  
  77.     public Customer setCpr(String cpr) {
  78.         this.cpr = cpr;
  79.         return this;
  80.     }
  81.  
  82.     public String getCreditCardNumber() {
  83.         return creditCardNumber;
  84.     }
  85.  
  86.     public Customer setCreditCardNumber(String creditCardNumber) {
  87.         this.creditCardNumber = creditCardNumber;
  88.         return this;
  89.     }
  90.  
  91.     public String getCreditCardExpiration() {
  92.         return creditCardExpiration;
  93.     }
  94.  
  95.     public Customer setCreditCardExpiration(String creditCardExpiration) {
  96.         this.creditCardExpiration = creditCardExpiration;
  97.         return this;
  98.     }
  99.  
  100.     public String getCreditCardCvc() {
  101.         return creditCardCvc;
  102.     }
  103.  
  104.     public Customer setCreditCardCvc(String creditCardCvc) {
  105.         this.creditCardCvc = creditCardCvc;
  106.         return this;
  107.     }
  108.  
  109.     // added these functions
  110.     public void setUsername(String username) {
  111.         this.username = username;
  112.     }
  113.  
  114.     public void setPassword(String password) {
  115.         this.password = password;
  116.     }
  117.  
  118.     public String getUsername() {
  119.         return username;
  120.     }
  121.  
  122.     public void setUsername() {
  123.         this.username = firstName.substring(0, 1) + lastName.substring(0, 3);
  124.     }
  125.  
  126.     public String getPassword() {
  127.         return password;
  128.     }
  129.  
  130.     public void setPassword() {
  131.         this.password = lastName.substring(0, 3) + cpr.substring(7, 11);
  132.     }
  133.  
  134.     public void writetoFile() {
  135.         String details = lastName + "; " + firstName + ";" + username + ";" + password + ";" + address + ";" + cpr + ";"
  136.                 + email + ";";
  137.         FileManipulation.WriteDetails("customer.txt", details);
  138.  
  139.     }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement