Advertisement
Art_Uspen

Untitled

Feb 16th, 2022
1,100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.77 KB | None | 0 0
  1. public class Person {
  2.     protected String name;
  3.     protected int age;
  4.     protected String login;
  5.     protected String password;
  6.  
  7.     public Person(PersonBuilder personBuilder) {
  8.         this.name = personBuilder.name;
  9.         this.age = personBuilder.age;
  10.         this.login = personBuilder.login;
  11.         this.password = personBuilder.password;
  12.     }
  13.     public static class PersonBuilder {
  14.         protected String name;
  15.         protected int age;
  16.         protected String login;
  17.         protected String password;
  18.         public PersonBuilder(){
  19.             super();
  20.         }
  21.         public PersonBuilder name(String name){
  22.             this.name = name;
  23.             return this;
  24.         }
  25.         public PersonBuilder age(int age){
  26.             this.age = age;
  27.             return this;
  28.         }
  29.         public PersonBuilder login(String login){
  30.             this.login = login;
  31.             return this;
  32.         }
  33.         public PersonBuilder password(String password){
  34.             this.password = password;
  35.             return this;
  36.         }
  37.         public Person build(){
  38.             Person person = null;
  39.             person = new Person(this);
  40.             return person;
  41.         }
  42.     }
  43.  
  44.     public String getName() {
  45.         return name;
  46.     }
  47.  
  48.     public void setName(String name) {
  49.         this.name = name;
  50.     }
  51.  
  52.     public int getAge() {
  53.         return age;
  54.     }
  55.  
  56.     public void setAge(int age) {
  57.         this.age = age;
  58.     }
  59.  
  60.     public String getLogin() {
  61.         return login;
  62.     }
  63.  
  64.     public void setLogin(String login) {
  65.         this.login = login;
  66.     }
  67.  
  68.     public String getPassword() {
  69.         return password;
  70.     }
  71.  
  72.     public void setPassword(String password) {
  73.         this.password = password;
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement