Advertisement
jolenic

Methods for Adding Users

Oct 27th, 2020
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. To create User objects:
  2. --for each type, I have two constructors, one with only the basics and one with all info. Feel free to just choose for now i guess :)
  3.  
  4. STUDENT:
  5. public Student(String userName, String password, String email) {
  6. super(userName, password, email);
  7. super.setRole("S");
  8. }
  9.  
  10. public Student(String userName, String firstName, String lastName, String email, String password) {
  11. super(userName, firstName, lastName, email, password);
  12. super.setRole("S");
  13. }
  14.  
  15. TEACHER:
  16. public Teacher(String userName, String firstName, String lastName, String email, String password) {
  17. super(userName, firstName, lastName, email, password);
  18. super.setRole("T");
  19. }
  20.  
  21. public Teacher(String userName, String password, String email) {
  22. super(userName, password, email);
  23. super.setRole("T");
  24. }
  25.  
  26. ADMIN:
  27. public Admin(String userName, String firstName, String lastName, String email, String password) {
  28. super(userName, firstName, lastName, email, password);
  29. super.setRole("A");
  30. }
  31.  
  32. public Admin(String userName, String password, String email) {
  33. super(userName, password, email);
  34. super.setRole("A");
  35. }
  36.  
  37. ADDING TO DB:
  38. //create AppDAO object
  39. AppDAO appDAO = new AppDAO();
  40.  
  41. //pass in User object (any of the three subclasses will work)
  42. appDAO.insertNewUser(user);
  43.  
  44. //profit!!?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement