Page 1 of 1

public class Customer { private String firstName; private String lastName; private int ID; private int numberPhone; priv

Posted: Thu May 26, 2022 9:07 am
by answerhappygod
Public Class Customer Private String Firstname Private String Lastname Private Int Id Private Int Numberphone Priv 1
Public Class Customer Private String Firstname Private String Lastname Private Int Id Private Int Numberphone Priv 1 (39.93 KiB) Viewed 15 times
Public Class Customer Private String Firstname Private String Lastname Private Int Id Private Int Numberphone Priv 2
Public Class Customer Private String Firstname Private String Lastname Private Int Id Private Int Numberphone Priv 2 (43.9 KiB) Viewed 15 times
Public Class Customer Private String Firstname Private String Lastname Private Int Id Private Int Numberphone Priv 3
Public Class Customer Private String Firstname Private String Lastname Private Int Id Private Int Numberphone Priv 3 (50.95 KiB) Viewed 15 times
public class Customer { private String firstName; private String lastName; private int ID; private int numberPhone; private String password; public String address; private int numberOfReadBook; public Customer(String firstName, String lastName, int ID, int numberPhone, String password, String address, int numberOfReadBook) { this.firstName= firstName; this.lastName= lastName; this.ID = ID; this.numberPhone numberPhone; this.password password; this.address = address; this.numberOfReadBook = numberOfReadBook; } String lastName, int ID, int numberPhone, String ublic Customer (String first password, String address) { this.firstName= firstName; this.lastName = lastName; this.ID = ID; this.numberPhone numberPhone; this.password = password; this.address address; this.numberOfReadBook = 0; this.firstName = ""; this.lastName = ""; this.ID = 0; this.numberPhone = 0; this.password = ""; this.address = ""; this.numberOfReadBook = 0; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName (String lastName) { this.lastName = lastName; } public int getID() { return ID; } public void setID(int ID) { this.ID = ID; } } public Customer() {
public int getNumberOfReadBook() { return numberOfReadBook; } public void setNumberOfReadBook(int numberOfReadBook) ( this.numberOfReadBook numberOfReadBook; } public int getNumberPhone() { return numberPhone; } public void setNumberPhone (int numberPhone) { this.numberPhone numberPhone; } public String getPassword() { return password; } public void setPassword(String password) { this.password password; } public String getAddress() { return address; } public void setAddress (String address) { this.address address; } @Override public String toString() ( return "firstName= + firstName + "\nlastName= " + lastName + "\nID=" + ID + "\nnumberPhone numberPhone + "\npassword="+password + "\naddress= " + address + "\nnumberOfReadBook + numberOfReadBook; } public String toPrint() { return "firstNames + firstName + "\nlastName= " + lastName + "\nID="ID + "\nnumberPhone= " + numberPhone + "\naddress=" + address; } // a function to create new file with number of customer then // save her/his information to the file public void SaveToFile() throws FileNotFoundException { File file = new File(numberPhone + ".txt"); Printwriter pw = new PrintWriter(file); pw.println(this); pw.close(); } // a function to get if user can login // to his account or not by number phone and password public boolean Login() { File file = new File(numberPhone + ".txt"); // if there is not any account with this number then cannot loggin if (!file.exists()) {
} // a function to get if user can login // to his account or not by number phone and password public boolean Login() { File file = new File(numberPhone + ".txt"); // if there is not any account with this number then cannot loggin if (!file.exists()) { return false; } else {//else try { Scanner scanner = new Scanner (file); //read information from file String fName = scanner.nextLine().split("= ")[1]; String 1Name = scanner.nextLine().split("= ")[1]; int ID = Integer.valueOf(scanner.nextLine().split(" ")[1]); int numberPhone = Integer.valueOf (scanner.nextLine().split("= ")[1]); String password = scanner.nextLine().split("= ")[1]; String address = scanner.nextLine().split("= ")[1]; int numberOfReadBook = Integer.valueOf (scanner.nextLine().split("= ")[1]); // if number phone and password are matched // then can loggin if (numberPhone == this.numberPhone && password.equals(this.password)) setFirstName (fName); setLastName (1Name); setID(ID); setAddress (address); set NumberOfReadBook (numberOfReadBook); return true; } catch (FileNotFoundException ex) { } // there is not any matched values return false;