Advertisement
Guest User

Untitled

a guest
Nov 21st, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 19.98 KB | None | 0 0
  1. package service;
  2.  
  3. import java.time.LocalDate;
  4. import java.util.ArrayList;
  5.  
  6. import model.Companion;
  7. import model.Conference;
  8. import model.Excursion;
  9. import model.Hotel;
  10. import model.Participant;
  11. import model.Registration;
  12. import model.Room;
  13. import storage.Storage;
  14.  
  15. public class Service {
  16.     /**
  17.      * Returns a list of all conferences.
  18.      */
  19.     public static ArrayList<Conference> getConferences() {
  20.         return Storage.getConferences();
  21.     }
  22.  
  23.     /**
  24.      * Creates a new Conference.<br />
  25.      */
  26.     public static Conference createConference(String title,
  27.         LocalDate startDate, LocalDate endDate, String location, double fee) {
  28.         Conference conference = new Conference(title, startDate, endDate,
  29.             location, fee);
  30.         Storage.addConference(conference);
  31.         return conference;
  32.     }
  33.  
  34.     /**
  35.      * Deletes the conference.<br />
  36.      */
  37.     public static void deleteConference(Conference conference) {
  38.         Storage.removeConference(conference);
  39.     }
  40.  
  41.     /**
  42.      * Updates the conference.<br />
  43.      */
  44.     public static void updateConference(Conference conference, String title,
  45.         LocalDate startDate, LocalDate endDate, String location, double fee) {
  46.         conference.setTitle(title);
  47.         conference.setStartDate(startDate);
  48.         conference.setEndDate(endDate);
  49.         conference.setLocation(location);
  50.         conference.setFee(fee);
  51.  
  52.     }
  53.  
  54.     // -----------------------------------------------------------------------------------------
  55.  
  56.     /**
  57.      * Returns a list of all participants.
  58.      */
  59.     public static ArrayList<Participant> getParticipants() {
  60.         return Storage.getParticipants();
  61.     }
  62.  
  63.     /**
  64.      * Returns a list of all participants to a certain conference.
  65.      */
  66.     public static ArrayList<Participant> getParticipantsToConference(
  67.         Conference conference) {
  68.         ArrayList<Participant> participantsToConf = new ArrayList<Participant>();
  69.         for (Registration reg : conference.getRegistrations()) {
  70.             participantsToConf.add(reg.getParticipant());
  71.         }
  72.         return participantsToConf;
  73.     }
  74.  
  75.     /**
  76.      * Creates a new participant.<br />
  77.      */
  78.     public static Participant createParticipant(String name, String iD,
  79.         String email, String phoneNumber, String address,
  80.         String occupation, String companyName, String companyPhone,
  81.         String cityCountry, LocalDate dateOfArrival,
  82.         LocalDate dateOfDeparture) {
  83.         Participant participant = new Participant(name, iD, email, phoneNumber,
  84.             address, occupation, companyName, companyPhone, cityCountry,
  85.             dateOfArrival, dateOfDeparture);
  86.         Storage.addParticipant(participant);
  87.         return participant;
  88.     }
  89.  
  90.     /**
  91.      * Creates registration
  92.      */
  93.  
  94.     public static void createRegistion(Participant participant,
  95.         boolean holdSpeech, boolean companion, Room room, double price) {
  96.         Storage.addRegistration(new Registration(participant, holdSpeech,
  97.             companion, room, price));
  98.     }
  99.  
  100.     /**
  101.      * Deletes a certain registration.
  102.      */
  103.     public static void deleteRegistrationFromConference(
  104.         Registration registration, Conference conference) {
  105.         if (conference != null) {
  106.             conference.removeRegistration(registration);
  107.         }
  108.  
  109.     }
  110.  
  111.     /**
  112.      * Updates the participant.<br />
  113.      */
  114.     public static void updateParticipant(Participant participant, String name,
  115.         String iD, String email, String phoneNumber, String address,
  116.         String occupation, String companyName, String companyPhone,
  117.         String cityCountry, LocalDate dateOfArrival,
  118.         LocalDate dateOfDeparture) {
  119.         participant.setName(name);
  120.         participant.setAddress(address);
  121.         participant.setOccupation(occupation);
  122.         participant.setCityCountry(cityCountry);
  123.         participant.setCompanyName(companyName);
  124.         participant.setCompanyPhone(companyPhone);
  125.         participant.setDateOfArrival(dateOfArrival);
  126.         participant.setDateOfDeparture(dateOfDeparture);
  127.         participant.setEmail(email);
  128.         participant.setID(iD);
  129.         participant.setPhoneNumber(phoneNumber);
  130.     }
  131.  
  132.     public static void deleteParticipant(Participant participant) {
  133.         Storage.removeParticipant(participant);
  134.  
  135.     }
  136.  
  137.     // ------------------------------------------------------------------------------------------
  138.  
  139.     /**
  140.      * Returns a list of all hotels.
  141.      */
  142.     public static ArrayList<Hotel> getHotels() {
  143.         return Storage.getHotels();
  144.     }
  145.  
  146.     /**
  147.      * Creates a new hotel.<br />
  148.      */
  149.     public static Hotel createHotel(String name, String address, String details) {
  150.         Hotel hotel = new Hotel(name, address, details);
  151.         Storage.addHotel(hotel);
  152.         return hotel;
  153.     }
  154.  
  155.     /**
  156.      * Deletes the hotel.<br />
  157.      */
  158.     public static void deleteHotel(Hotel hotel) {
  159.         Storage.removeHotel(hotel);
  160.     }
  161.  
  162.     /**
  163.      * Updates the conference.<br />
  164.      */
  165.     public static void updateHotel(Hotel hotel, String name, String address,
  166.         String details) {
  167.         hotel.setName(name);
  168.         hotel.setAddress(address);
  169.         hotel.setDetails(details);
  170.  
  171.     }
  172.  
  173.     // -----------------------------------------------------------------------------------------
  174.  
  175.     /**
  176.      * Returns a list of all excursions for a conference.
  177.      */
  178.     public static ArrayList<Excursion> getExcursions(Conference conf) {
  179.         return conf.getExcursions();
  180.     }
  181.  
  182.     /**
  183.      * Creates a new excursion for a certain conference.<br />
  184.      */
  185.     public static Excursion createExcursion(Conference conf, String place,
  186.         LocalDate date, double price, boolean lunch) {
  187.         Excursion excursion = new Excursion(place, date, price, lunch);
  188.         conf.addExcursion(excursion);
  189.         return excursion;
  190.     }
  191.  
  192.     /**
  193.      * Deletes the excursion from a certain conference.<br />
  194.      */
  195.     public static void deleteExcursion(Conference conf, Excursion excursion) {
  196.         conf.removeExcursion(excursion);
  197.     }
  198.  
  199.     /**
  200.      * Updates an excursion.<br />
  201.      */
  202.     public static void updateExcursion(Excursion excursion, String place,
  203.         LocalDate date, double price, boolean lunch) {
  204.         excursion.setDate(date);
  205.         excursion.setLunch(lunch);
  206.         excursion.setPlace(place);
  207.         excursion.setPrice(price);
  208.  
  209.     }
  210.  
  211.     // -------------------------------------------------------------------------------------
  212.  
  213.     public static void initStorage() {
  214.         Hotel h1 = new Hotel("The blue swan", "dsfdvfdgbfd 56",
  215.             "The rooms with extra services are provided "
  216.                 + "with WiFi and private bathrooms.");
  217.         Hotel h2 = new Hotel("Royal Duck", "sejhiueah 55",
  218.             "The rooms with estra services have "
  219.                 + "private bathrooms and a fridge.");
  220.         Hotel h3 = new Hotel("Intercontinental", "avhjdds 223",
  221.             "The rooms with extra services have WiFi, "
  222.                 + "private bathrooms, breakfast and lunch. ");
  223.         Hotel h4 = new Hotel("Exotic Paradise Hotel", "rhiuic 95",
  224.             "The rooms with extra services are "
  225.                 + "provided with a big balcony, "
  226.                 + "WiFi, private bathroom, breakfast, "
  227.                 + "lunch, dinner, waterbed, jacuzzi and TV.");
  228.         Hotel h5 = new Hotel("Ed Sheeran", "Main Street 33", "The rooms "
  229.             + "with extra services have a big room with TV, waterbed, "
  230.             + "fridge and WiFi");
  231.         Hotel h6 = new Hotel("Magic Hotel", "Rude Street 22",
  232.             "The rooms with extra services include breakfast and dinner.");
  233.         Hotel h7 = new Hotel("Tokio Hotel", "Monsoon 002",
  234.             "The rooms with extra services are provided "
  235.                 + "with WiFi and private bathrooms.");
  236.         Hotel h8 = new Hotel("30 Seconds to Mars", "The kill 25",
  237.             "The rooms with extra services are provided "
  238.                 + "with WiFi and TV.");
  239.         Hotel h9 = new Hotel("Nothig else matters", "Metallica 100",
  240.             "The rooms " + "with extra service have private bathroom.");
  241.         Hotel h10 = new Hotel("Martin Garrix", "Animals 65",
  242.             "The rooms with extra services are provided "
  243.                 + "with WiFi and private bathrooms.");
  244.         Storage.addHotel(h1);
  245.         Storage.addHotel(h2);
  246.         Storage.addHotel(h3);
  247.         Storage.addHotel(h4);
  248.         Storage.addHotel(h5);
  249.         Storage.addHotel(h6);
  250.         Storage.addHotel(h7);
  251.         Storage.addHotel(h8);
  252.         Storage.addHotel(h9);
  253.         Storage.addHotel(h10);
  254.  
  255.         Conference c1 = new Conference("A World of Opportunities",
  256.             LocalDate.of(2014, 12, 10), LocalDate.of(2014, 12, 15),
  257.             "Rosenhoj 4B", 299.99);
  258.         Conference c2 = new Conference("Back to the Future", LocalDate.of(2015,
  259.             02, 05), LocalDate.of(2015, 02, 12), "AROS", 60.00);
  260.         Conference c3 = new Conference("Customer Focus", LocalDate.of(2015, 03,
  261.             03), LocalDate.of(2015, 03, 10), "Tokyo", 250);
  262.         Conference c4 = new Conference("Innovate, Integrate, Motivate",
  263.             LocalDate.of(2015, 05, 10), LocalDate.of(2015, 05, 22),
  264.             "London", 780);
  265.         Storage.addConference(c1);
  266.         Storage.addConference(c2);
  267.         Storage.addConference(c3);
  268.         Storage.addConference(c4);
  269.  
  270.         c1.addHotel(h1);
  271.         c1.addHotel(h2);
  272.         c1.addHotel(h3);
  273.         c1.addHotel(h4);
  274.         c1.addHotel(h5);
  275.         c2.addHotel(h5);
  276.         c2.addHotel(h6);
  277.         c2.addHotel(h7);
  278.         c3.addHotel(h6);
  279.         c3.addHotel(h7);
  280.         c4.addHotel(h8);
  281.         c4.addHotel(h9);
  282.         c4.addHotel(h10);
  283.  
  284.         h1.addConference(c1);
  285.         h2.addConference(c1);
  286.         h3.addConference(c1);
  287.         h4.addConference(c1);
  288.         h5.addConference(c1);
  289.         h5.addConference(c2);
  290.         h6.addConference(c2);
  291.         h6.addConference(c3);
  292.         h7.addConference(c2);
  293.         h7.addConference(c3);
  294.         h8.addConference(c4);
  295.         h9.addConference(c4);
  296.         h10.addConference(c4);
  297.  
  298.         Participant p1 = new Participant("Mikael Christensen", "BRDN265438I98",
  299.             "mikael@email.com", "75869845", "Verona 55", "Employee",
  300.             "UNMC", "331546345", "Rome", LocalDate.of(2014, 12, 11),
  301.             LocalDate.of(2014, 12, 13));
  302.         Participant p2 = new Participant("Daniel Radoev", "DRD65846LD454",
  303.             "Daniel@radoev.com", "51248965", "Aarhus C", "Student", null,
  304.             null, "Denmark", LocalDate.of(2015, 05, 11), LocalDate.of(2015,
  305.                 03, 20));
  306.         Participant p3 = new Participant("Adrian Mos", "AMS46845AD46584",
  307.             "adi@adrian.dk", "56241782", "Tilst 87", "Employee", "Arla",
  308.             "565451546", "Romania", LocalDate.of(2014, 12, 10),
  309.             LocalDate.of(2014, 12, 15));
  310.         Participant p4 = new Participant("Aurora Brignola", "AUBRG165465AR8",
  311.             "aurora@gmail.com", "52687438", "Rosenhoj 4B", "Student", null,
  312.             null, "Italy", LocalDate.of(2014, 12, 12), LocalDate.of(2014,
  313.                 12, 14));
  314.         Participant p5 = new Participant("Diana Barbu", "DIBB4656D37",
  315.             "diana@yahoo.com", "54876484", "Brabrand 11", "Employee",
  316.             "Oracle", "54845493", "Portugal", LocalDate.of(2015, 02, 05),
  317.             LocalDate.of(2015, 02, 12));
  318.         Participant p6 = new Participant("Andrei Ciurea", "ADCR484135R52",
  319.             "andi@hotmal.com", "6485792", "London 75", "Retired", null,
  320.             null, "Dubai", LocalDate.of(2015, 02, 06), LocalDate.of(2015,
  321.                 02, 8));
  322.         Participant p7 = new Participant("Attila Szigmond", "ATSZ654897",
  323.             "attila@hotmail.com", "54798632", "Heaven 76", "Retired", null,
  324.             null, "Mumbay", LocalDate.of(2015, 03, 03), LocalDate.of(2015,
  325.                 03, 10));
  326.         Participant p8 = new Participant("Elena Stanila", "ELST684",
  327.             "elena@kcc.com", "486415685", "Decebal 67", "Employee",
  328.             "Genpact", "684545663", "Bucharest",
  329.             LocalDate.of(2015, 03, 03), LocalDate.of(2015, 03, 9));
  330.  
  331.         Storage.addParticipant(p1);
  332.         Storage.addParticipant(p2);
  333.         Storage.addParticipant(p3);
  334.         Storage.addParticipant(p4);
  335.         Storage.addParticipant(p5);
  336.         Storage.addParticipant(p6);
  337.         Storage.addParticipant(p7);
  338.         Storage.addParticipant(p8);
  339.  
  340.         Companion comp1 = new Companion("Adrian", "48465-65", "adrian@adi.com",
  341.             "6486433");
  342.         Companion comp2 = new Companion("Rasmus", "949854-6558",
  343.             "rasmus@eaaa.dk", "95655652");
  344.         Companion comp3 = new Companion("Artis", "469454-6588",
  345.             "artis@eaaa.dk", "68768454");
  346.         Companion comp4 = new Companion("Vlade", "149195-9784",
  347.             "vlade@eaaa.dk", "446845165");
  348.         Companion comp5 = new Companion("Pernille", "469416-7421",
  349.             "pernille@eaaa.dk", "45695451");
  350.         Companion comp6 = new Companion("Jakub", "116981-9862", "kuba@eaaa.dk",
  351.             "54648616");
  352.         Companion comp7 = new Companion("Pawel", "35469-9871", "pawel@eaaa.dk",
  353.             "364564565");
  354.  
  355.         Excursion ex1 = new Excursion("Trip to Gordisnel", LocalDate.of(2014,
  356.             12, 12), 249.99, true);
  357.         Excursion ex2 = new Excursion("Swim with dolphins", LocalDate.of(2014,
  358.             12, 13), 125, false);
  359.         Excursion ex3 = new Excursion("Trip to the mountains", LocalDate.of(
  360.             2015, 02, 8), 379.99, true);
  361.         Excursion ex4 = new Excursion("A day at the seaside", LocalDate.of(
  362.             2015, 03, 7), 50, false);
  363.         Excursion ex5 = new Excursion("Visit the old city", LocalDate.of(2015,
  364.             03, 9), 75, false);
  365.         Excursion ex6 = new Excursion("Visit some ruins", LocalDate.of(2015,
  366.             05, 11), 45, false);
  367.         Excursion ex7 = new Excursion("A day at spa",
  368.             LocalDate.of(2015, 05, 12), 120, false);
  369.         Excursion ex8 = new Excursion("Tour of the city", LocalDate.of(2015,
  370.             05, 13), 39.99, false);
  371.         Excursion ex9 = new Excursion("A day with the queen", LocalDate.of(
  372.             2015, 05, 14), 185, true);
  373.         Excursion ex10 = new Excursion("Meet the president", LocalDate.of(2015,
  374.             05, 15), 25, false);
  375.         Excursion ex11 = new Excursion("Visit the volcano", LocalDate.of(2015,
  376.             05, 20), 220, true);
  377.  
  378.         ex1.addConference(c1);
  379.         c1.addExcursion(ex1);
  380.         ex2.addConference(c2);
  381.         c2.addExcursion(ex2);
  382.         ex3.addConference(c3);
  383.         c3.addExcursion(ex3);
  384.         ex4.addConference(c4);
  385.         c4.addExcursion(ex4);
  386.         ex5.addConference(c1);
  387.         c1.addExcursion(ex5);
  388.         ex6.addConference(c1);
  389.         c1.addExcursion(ex6);
  390.         ex7.addConference(c1);
  391.         c1.addExcursion(ex7);
  392.         ex8.addConference(c1);
  393.         c1.addExcursion(ex8);
  394.         ex9.addConference(c1);
  395.         c1.addExcursion(ex9);
  396.         ex10.addConference(c1);
  397.         c1.addExcursion(ex10);
  398.         ex11.addConference(c1);
  399.         c1.addExcursion(ex11);
  400.  
  401.         ex1.addCompanion(comp1);
  402.         ex1.addCompanion(comp2);
  403.         ex1.addCompanion(comp3);
  404.         ex1.addCompanion(comp4);
  405.         ex1.addCompanion(comp5);
  406.         ex2.addCompanion(comp1);
  407.         ex2.addCompanion(comp2);
  408.         ex2.addCompanion(comp3);
  409.         ex3.addCompanion(comp4);
  410.         ex3.addCompanion(comp5);
  411.         ex3.addCompanion(comp6);
  412.         ex3.addCompanion(comp7);
  413.         ex4.addCompanion(comp1);
  414.         ex4.addCompanion(comp2);
  415.         ex5.addCompanion(comp3);
  416.         ex5.addCompanion(comp4);
  417.         ex5.addCompanion(comp5);
  418.         ex6.addCompanion(comp6);
  419.         ex6.addCompanion(comp7);
  420.         ex7.addCompanion(comp1);
  421.         ex8.addCompanion(comp2);
  422.         ex8.addCompanion(comp3);
  423.         ex9.addCompanion(comp4);
  424.         ex10.addCompanion(comp5);
  425.         ex11.addCompanion(comp6);
  426.         ex11.addCompanion(comp7);
  427.  
  428.         comp1.addExcursion(ex1);
  429.         comp2.addExcursion(ex1);
  430.         comp3.addExcursion(ex1);
  431.         comp4.addExcursion(ex1);
  432.         comp5.addExcursion(ex1);
  433.         comp6.addExcursion(ex1);
  434.         comp7.addExcursion(ex1);
  435.  
  436.         comp1.addExcursion(ex2);
  437.         comp2.addExcursion(ex2);
  438.         comp3.addExcursion(ex2);
  439.         comp4.addExcursion(ex3);
  440.         comp5.addExcursion(ex3);
  441.         comp6.addExcursion(ex3);
  442.         comp7.addExcursion(ex3);
  443.  
  444.         comp1.addExcursion(ex4);
  445.         comp2.addExcursion(ex4);
  446.         comp3.addExcursion(ex5);
  447.         comp4.addExcursion(ex5);
  448.         comp5.addExcursion(ex5);
  449.         comp6.addExcursion(ex6);
  450.         comp7.addExcursion(ex6);
  451.  
  452.         comp1.addExcursion(ex7);
  453.         comp2.addExcursion(ex8);
  454.         comp3.addExcursion(ex8);
  455.         comp4.addExcursion(ex9);
  456.         comp5.addExcursion(ex10);
  457.         comp6.addExcursion(ex11);
  458.         comp7.addExcursion(ex11);
  459.  
  460.         Room room1 = new Room("Double", true, 660);
  461.         Room room2 = new Room("Double", true, 789.99);
  462.         Room room3 = new Room("Double", false, 645);
  463.         Room room4 = new Room("Double", false, 478);
  464.         Room room5 = new Room("Double", true, 879.99);
  465.         Room room6 = new Room("Double", false, 500);
  466.         Room room7 = new Room("Single", false, 450);
  467.         Room room8 = new Room("Single", true, 420);
  468.  
  469.         h1.addRoom(room1);
  470.         h1.addRoom(room2);
  471.         h1.addRoom(room3);
  472.         h2.addRoom(room4);
  473.         h2.addRoom(room5);
  474.         h3.addRoom(room6);
  475.         h3.addRoom(room7);
  476.         h3.addRoom(room8);
  477.  
  478.         room1.setHotel(h1);
  479.         room2.setHotel(h1);
  480.         room3.setHotel(h1);
  481.         room4.setHotel(h2);
  482.         room5.setHotel(h2);
  483.         room6.setHotel(h3);
  484.         room7.setHotel(h3);
  485.         room8.setHotel(h3);
  486.  
  487.         Registration reg1 = new Registration(p1, true, true, room1, 2734);
  488.         Registration reg2 = new Registration(p2, false, true, room2, 5676.45);
  489.         Registration reg3 = new Registration(p3, true, true, room8, 874);
  490.         Registration reg4 = new Registration(p4, false, true, room4, 3543.5);
  491.         Registration reg5 = new Registration(p5, false, true, room3, 4367);
  492.         Registration reg6 = new Registration(p6, true, true, room5, 5765);
  493.         Registration reg7 = new Registration(p7, false, true, room7, 4354);
  494.         Registration reg8 = new Registration(p8, true, true, room6, 3464);
  495.  
  496.         reg1.setParticipant(p1);
  497.         reg2.setParticipant(p2);
  498.         reg3.setParticipant(p3);
  499.         reg4.setParticipant(p4);
  500.         reg5.setParticipant(p5);
  501.         reg6.setParticipant(p6);
  502.         reg7.setParticipant(p7);
  503.         reg8.setParticipant(p8);
  504.  
  505.         p1.addRegistration(reg1);
  506.         p2.addRegistration(reg2);
  507.         p3.addRegistration(reg3);
  508.         p4.addRegistration(reg4);
  509.         p5.addRegistration(reg5);
  510.         p6.addRegistration(reg6);
  511.         p7.addRegistration(reg7);
  512.         p8.addRegistration(reg8);
  513.  
  514.         reg1.setConference(c4);
  515.         reg2.setConference(c3);
  516.         reg3.setConference(c2);
  517.         reg4.setConference(c2);
  518.         reg5.setConference(c1);
  519.         reg6.setConference(c1);
  520.         reg7.setConference(c1);
  521.         reg8.setConference(c1);
  522.  
  523.         reg1.setCompanion(comp1);
  524.         reg2.setCompanion(comp2);
  525.         reg3.setCompanion(comp3);
  526.         reg4.setCompanion(comp4);
  527.         reg5.setCompanion(comp5);
  528.         reg6.setCompanion(comp6);
  529.         reg7.setCompanion(comp7);
  530.  
  531.         comp1.addRegistration(reg1);
  532.         comp2.addRegistration(reg2);
  533.         comp3.addRegistration(reg3);
  534.         comp4.addRegistration(reg4);
  535.         comp5.addRegistration(reg5);
  536.         comp6.addRegistration(reg6);
  537.         comp7.addRegistration(reg7);
  538.  
  539.         c1.addRegistrations(reg8);
  540.         c1.addRegistrations(reg7);
  541.         c1.addRegistrations(reg6);
  542.         c1.addRegistrations(reg5);
  543.         c2.addRegistrations(reg4);
  544.         c2.addRegistrations(reg3);
  545.         c3.addRegistrations(reg2);
  546.         c4.addRegistrations(reg1);
  547.  
  548.     }
  549. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement