Advertisement
Guest User

Untitled

a guest
Mar 24th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Iterator;
  3.  
  4. /**
  5. * Created by El_Diablo on 3/6/2016.
  6. * Class "Admin" creates the password and username for the administrator.
  7. * Administrator can later add Members.
  8. */
  9.  
  10. public class Admin extends Person {
  11.  
  12. public static int num = 0;
  13. private String password;
  14. private String username;
  15.  
  16. /**
  17. * @param name
  18. * @param surname Constructor calls method "getNum" so every time an object is created, a static number is increased
  19. */
  20. Admin(String name, String surname) {
  21. super(name, surname);
  22. getNum();
  23. }
  24.  
  25. /**
  26. * Constructor of Admin, calls the constructor of super class(Person) and passes the number of admin as an argument
  27. */
  28. Admin() {
  29. super("Administrator", getNum());
  30. }
  31.  
  32. /**
  33. * method to get the number of created Admins
  34. */
  35. public static String getNum() {
  36. num++;
  37. return Integer.toString(num);
  38. }
  39.  
  40. /**
  41. * @param username setter of username
  42. */
  43. public void setUsername(String username) {
  44. this.username = username;
  45. }
  46.  
  47. /**
  48. * @param password setter of password
  49. */
  50. public void setPassword(String password) {
  51. this.password = password;
  52. }
  53.  
  54. /**
  55. * getter of username
  56. */
  57. public String getUsername() {
  58. return username;
  59. }
  60.  
  61. /**
  62. * getter of password
  63. */
  64. public String getPassword() {
  65. return password;
  66. }
  67.  
  68. /**
  69. * Methods for creating Members in ArrayList. Each admin can add members to the same arraylist.
  70. */
  71. static ArrayList<Member> members = new ArrayList<Member>();
  72.  
  73.  
  74. /**
  75. * @param name
  76. * @param surname Method for filling an array list with members
  77. */
  78. public void newMembers(String name, String surname) {
  79.  
  80. members.add(new Member(name, surname));
  81. }
  82.  
  83. /**
  84. * Method to make pretty text
  85. */
  86. public String toString() {
  87. return "Name of the admin : " + this.getName() + '\n' + "Surname of the admin : "
  88. + this.getSurname() + '\n' + "Identification number : " + this.getId() + '\n';
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement