Sclafus

coso.txt

Oct 20th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. /**
  2. * Main method. This method is called automatically
  3. * when the program is executed.
  4. * @param args main arguments
  5. */
  6. public static void main(String[] args) {
  7. Club club = new Club();
  8. club.test_main(club);
  9. }
  10.  
  11. /**
  12. * Actual main method, invoked by {@code main} method.
  13. * This method is used because the {@code main} method needs
  14. * to be static.
  15. * @param club the entire club. [Club]
  16. * @see main
  17. */
  18. public void test_main(Club club) {
  19.  
  20. //1) Adding an admin, some users and some activities
  21. Admin owner = new Admin("Jeff","Bezos","[email protected]","unaPasswordMoltoStrong");
  22.  
  23. owner.addUser(club, "Francesco", "Petrarca", "[email protected]","canzoniereRules");
  24. owner.addUser(club, "Jean Baptiste Joseph", "Fourier", "[email protected]","iLoveDirac");
  25. owner.addUser(club, "Dmitrij Ivanovic", "Mendeleev", "[email protected]", "atomicNumbersRules");
  26. owner.addUser(club, "tmp", "tmp", "[email protected]", "passwd");
  27. owner.addLesson(club, "Pallavolo");
  28. owner.addLesson(club, "Pilates");
  29. owner.addRace(club, "Tiro con l'arco");
  30. owner.addRace(club, "Karate");
  31.  
  32. //2) modifing&removing users
  33. owner.setEmail(club.users.get(3), "[email protected]");
  34. owner.setName(club.users.get(3), "new_name");
  35. owner.setSurname(club.users.get(3), "new_surname");
  36. owner.removePeople(club, club.users.get(3));
  37.  
  38. //3) choosing a random user
  39. Random rand = new Random();
  40. User rand_user = club.users.get(rand.nextInt(club.users.size()));
  41.  
  42. //4.1) the user subscribes to a race and a lesson
  43. Lesson rand_less = club.lessons.get(rand.nextInt(club.lessons.size()));
  44. Race rand_race = club.races.get(rand.nextInt(club.races.size()));
  45. rand_user.subscribeLesson(rand_less);
  46. rand_user.subscribeRace(rand_race);
  47.  
  48. //4.2) unsubscribing from random activity
  49. if(rand.nextInt(2) == 1){
  50. rand_user.unsubscribeLesson(rand_less);
  51. } else {
  52. rand_user.unsubscribeRace(rand_race);
  53. }
  54.  
  55. //5)presenting data
  56. printLessons(club);
  57. printRaces(club);
  58. printUsers(club);
  59. }
Advertisement
Add Comment
Please, Sign In to add comment