Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package service;
- import java.time.LocalDate;
- import java.util.ArrayList;
- import model.Companion;
- import model.Conference;
- import model.Excursion;
- import model.Hotel;
- import model.Participant;
- import model.Registration;
- import model.Room;
- import storage.Storage;
- public class Service {
- /**
- * Returns a list of all conferences.
- */
- public static ArrayList<Conference> getConferences() {
- return Storage.getConferences();
- }
- /**
- * Creates a new Conference.<br />
- */
- public static Conference createConference(String title,
- LocalDate startDate, LocalDate endDate, String location, double fee) {
- Conference conference = new Conference(title, startDate, endDate,
- location, fee);
- Storage.addConference(conference);
- return conference;
- }
- /**
- * Deletes the conference.<br />
- */
- public static void deleteConference(Conference conference) {
- Storage.removeConference(conference);
- }
- /**
- * Updates the conference.<br />
- */
- public static void updateConference(Conference conference, String title,
- LocalDate startDate, LocalDate endDate, String location, double fee) {
- conference.setTitle(title);
- conference.setStartDate(startDate);
- conference.setEndDate(endDate);
- conference.setLocation(location);
- conference.setFee(fee);
- }
- // -----------------------------------------------------------------------------------------
- /**
- * Returns a list of all participants.
- */
- public static ArrayList<Participant> getParticipants() {
- return Storage.getParticipants();
- }
- /**
- * Returns a list of all participants to a certain conference.
- */
- public static ArrayList<Participant> getParticipantsToConference(
- Conference conference) {
- ArrayList<Participant> participantsToConf = new ArrayList<Participant>();
- for (Registration reg : conference.getRegistrations()) {
- participantsToConf.add(reg.getParticipant());
- }
- return participantsToConf;
- }
- /**
- * Creates a new participant.<br />
- */
- public static Participant createParticipant(String name, String iD,
- String email, String phoneNumber, String address,
- String occupation, String companyName, String companyPhone,
- String cityCountry, LocalDate dateOfArrival,
- LocalDate dateOfDeparture) {
- Participant participant = new Participant(name, iD, email, phoneNumber,
- address, occupation, companyName, companyPhone, cityCountry,
- dateOfArrival, dateOfDeparture);
- Storage.addParticipant(participant);
- return participant;
- }
- /**
- * Creates registration
- */
- public static void createRegistion(Participant participant,
- boolean holdSpeech, boolean companion, Room room, double price) {
- Storage.addRegistration(new Registration(participant, holdSpeech,
- companion, room, price));
- }
- /**
- * Deletes a certain registration.
- */
- public static void deleteRegistrationFromConference(
- Registration registration, Conference conference) {
- if (conference != null) {
- conference.removeRegistration(registration);
- }
- }
- /**
- * Updates the participant.<br />
- */
- public static void updateParticipant(Participant participant, String name,
- String iD, String email, String phoneNumber, String address,
- String occupation, String companyName, String companyPhone,
- String cityCountry, LocalDate dateOfArrival,
- LocalDate dateOfDeparture) {
- participant.setName(name);
- participant.setAddress(address);
- participant.setOccupation(occupation);
- participant.setCityCountry(cityCountry);
- participant.setCompanyName(companyName);
- participant.setCompanyPhone(companyPhone);
- participant.setDateOfArrival(dateOfArrival);
- participant.setDateOfDeparture(dateOfDeparture);
- participant.setEmail(email);
- participant.setID(iD);
- participant.setPhoneNumber(phoneNumber);
- }
- public static void deleteParticipant(Participant participant) {
- Storage.removeParticipant(participant);
- }
- // ------------------------------------------------------------------------------------------
- /**
- * Returns a list of all hotels.
- */
- public static ArrayList<Hotel> getHotels() {
- return Storage.getHotels();
- }
- /**
- * Creates a new hotel.<br />
- */
- public static Hotel createHotel(String name, String address, String details) {
- Hotel hotel = new Hotel(name, address, details);
- Storage.addHotel(hotel);
- return hotel;
- }
- /**
- * Deletes the hotel.<br />
- */
- public static void deleteHotel(Hotel hotel) {
- Storage.removeHotel(hotel);
- }
- /**
- * Updates the conference.<br />
- */
- public static void updateHotel(Hotel hotel, String name, String address,
- String details) {
- hotel.setName(name);
- hotel.setAddress(address);
- hotel.setDetails(details);
- }
- // -----------------------------------------------------------------------------------------
- /**
- * Returns a list of all excursions for a conference.
- */
- public static ArrayList<Excursion> getExcursions(Conference conf) {
- return conf.getExcursions();
- }
- /**
- * Creates a new excursion for a certain conference.<br />
- */
- public static Excursion createExcursion(Conference conf, String place,
- LocalDate date, double price, boolean lunch) {
- Excursion excursion = new Excursion(place, date, price, lunch);
- conf.addExcursion(excursion);
- return excursion;
- }
- /**
- * Deletes the excursion from a certain conference.<br />
- */
- public static void deleteExcursion(Conference conf, Excursion excursion) {
- conf.removeExcursion(excursion);
- }
- /**
- * Updates an excursion.<br />
- */
- public static void updateExcursion(Excursion excursion, String place,
- LocalDate date, double price, boolean lunch) {
- excursion.setDate(date);
- excursion.setLunch(lunch);
- excursion.setPlace(place);
- excursion.setPrice(price);
- }
- // -------------------------------------------------------------------------------------
- public static void initStorage() {
- Hotel h1 = new Hotel("The blue swan", "dsfdvfdgbfd 56",
- "The rooms with extra services are provided "
- + "with WiFi and private bathrooms.");
- Hotel h2 = new Hotel("Royal Duck", "sejhiueah 55",
- "The rooms with estra services have "
- + "private bathrooms and a fridge.");
- Hotel h3 = new Hotel("Intercontinental", "avhjdds 223",
- "The rooms with extra services have WiFi, "
- + "private bathrooms, breakfast and lunch. ");
- Hotel h4 = new Hotel("Exotic Paradise Hotel", "rhiuic 95",
- "The rooms with extra services are "
- + "provided with a big balcony, "
- + "WiFi, private bathroom, breakfast, "
- + "lunch, dinner, waterbed, jacuzzi and TV.");
- Hotel h5 = new Hotel("Ed Sheeran", "Main Street 33", "The rooms "
- + "with extra services have a big room with TV, waterbed, "
- + "fridge and WiFi");
- Hotel h6 = new Hotel("Magic Hotel", "Rude Street 22",
- "The rooms with extra services include breakfast and dinner.");
- Hotel h7 = new Hotel("Tokio Hotel", "Monsoon 002",
- "The rooms with extra services are provided "
- + "with WiFi and private bathrooms.");
- Hotel h8 = new Hotel("30 Seconds to Mars", "The kill 25",
- "The rooms with extra services are provided "
- + "with WiFi and TV.");
- Hotel h9 = new Hotel("Nothig else matters", "Metallica 100",
- "The rooms " + "with extra service have private bathroom.");
- Hotel h10 = new Hotel("Martin Garrix", "Animals 65",
- "The rooms with extra services are provided "
- + "with WiFi and private bathrooms.");
- Storage.addHotel(h1);
- Storage.addHotel(h2);
- Storage.addHotel(h3);
- Storage.addHotel(h4);
- Storage.addHotel(h5);
- Storage.addHotel(h6);
- Storage.addHotel(h7);
- Storage.addHotel(h8);
- Storage.addHotel(h9);
- Storage.addHotel(h10);
- Conference c1 = new Conference("A World of Opportunities",
- LocalDate.of(2014, 12, 10), LocalDate.of(2014, 12, 15),
- "Rosenhoj 4B", 299.99);
- Conference c2 = new Conference("Back to the Future", LocalDate.of(2015,
- 02, 05), LocalDate.of(2015, 02, 12), "AROS", 60.00);
- Conference c3 = new Conference("Customer Focus", LocalDate.of(2015, 03,
- 03), LocalDate.of(2015, 03, 10), "Tokyo", 250);
- Conference c4 = new Conference("Innovate, Integrate, Motivate",
- LocalDate.of(2015, 05, 10), LocalDate.of(2015, 05, 22),
- "London", 780);
- Storage.addConference(c1);
- Storage.addConference(c2);
- Storage.addConference(c3);
- Storage.addConference(c4);
- c1.addHotel(h1);
- c1.addHotel(h2);
- c1.addHotel(h3);
- c1.addHotel(h4);
- c1.addHotel(h5);
- c2.addHotel(h5);
- c2.addHotel(h6);
- c2.addHotel(h7);
- c3.addHotel(h6);
- c3.addHotel(h7);
- c4.addHotel(h8);
- c4.addHotel(h9);
- c4.addHotel(h10);
- h1.addConference(c1);
- h2.addConference(c1);
- h3.addConference(c1);
- h4.addConference(c1);
- h5.addConference(c1);
- h5.addConference(c2);
- h6.addConference(c2);
- h6.addConference(c3);
- h7.addConference(c2);
- h7.addConference(c3);
- h8.addConference(c4);
- h9.addConference(c4);
- h10.addConference(c4);
- Participant p1 = new Participant("Mikael Christensen", "BRDN265438I98",
- "mikael@email.com", "75869845", "Verona 55", "Employee",
- "UNMC", "331546345", "Rome", LocalDate.of(2014, 12, 11),
- LocalDate.of(2014, 12, 13));
- Participant p2 = new Participant("Daniel Radoev", "DRD65846LD454",
- "Daniel@radoev.com", "51248965", "Aarhus C", "Student", null,
- null, "Denmark", LocalDate.of(2015, 05, 11), LocalDate.of(2015,
- 03, 20));
- Participant p3 = new Participant("Adrian Mos", "AMS46845AD46584",
- "adi@adrian.dk", "56241782", "Tilst 87", "Employee", "Arla",
- "565451546", "Romania", LocalDate.of(2014, 12, 10),
- LocalDate.of(2014, 12, 15));
- Participant p4 = new Participant("Aurora Brignola", "AUBRG165465AR8",
- "aurora@gmail.com", "52687438", "Rosenhoj 4B", "Student", null,
- null, "Italy", LocalDate.of(2014, 12, 12), LocalDate.of(2014,
- 12, 14));
- Participant p5 = new Participant("Diana Barbu", "DIBB4656D37",
- "diana@yahoo.com", "54876484", "Brabrand 11", "Employee",
- "Oracle", "54845493", "Portugal", LocalDate.of(2015, 02, 05),
- LocalDate.of(2015, 02, 12));
- Participant p6 = new Participant("Andrei Ciurea", "ADCR484135R52",
- "andi@hotmal.com", "6485792", "London 75", "Retired", null,
- null, "Dubai", LocalDate.of(2015, 02, 06), LocalDate.of(2015,
- 02, 8));
- Participant p7 = new Participant("Attila Szigmond", "ATSZ654897",
- "attila@hotmail.com", "54798632", "Heaven 76", "Retired", null,
- null, "Mumbay", LocalDate.of(2015, 03, 03), LocalDate.of(2015,
- 03, 10));
- Participant p8 = new Participant("Elena Stanila", "ELST684",
- "elena@kcc.com", "486415685", "Decebal 67", "Employee",
- "Genpact", "684545663", "Bucharest",
- LocalDate.of(2015, 03, 03), LocalDate.of(2015, 03, 9));
- Storage.addParticipant(p1);
- Storage.addParticipant(p2);
- Storage.addParticipant(p3);
- Storage.addParticipant(p4);
- Storage.addParticipant(p5);
- Storage.addParticipant(p6);
- Storage.addParticipant(p7);
- Storage.addParticipant(p8);
- Companion comp1 = new Companion("Adrian", "48465-65", "adrian@adi.com",
- "6486433");
- Companion comp2 = new Companion("Rasmus", "949854-6558",
- "rasmus@eaaa.dk", "95655652");
- Companion comp3 = new Companion("Artis", "469454-6588",
- "artis@eaaa.dk", "68768454");
- Companion comp4 = new Companion("Vlade", "149195-9784",
- "vlade@eaaa.dk", "446845165");
- Companion comp5 = new Companion("Pernille", "469416-7421",
- "pernille@eaaa.dk", "45695451");
- Companion comp6 = new Companion("Jakub", "116981-9862", "kuba@eaaa.dk",
- "54648616");
- Companion comp7 = new Companion("Pawel", "35469-9871", "pawel@eaaa.dk",
- "364564565");
- Excursion ex1 = new Excursion("Trip to Gordisnel", LocalDate.of(2014,
- 12, 12), 249.99, true);
- Excursion ex2 = new Excursion("Swim with dolphins", LocalDate.of(2014,
- 12, 13), 125, false);
- Excursion ex3 = new Excursion("Trip to the mountains", LocalDate.of(
- 2015, 02, 8), 379.99, true);
- Excursion ex4 = new Excursion("A day at the seaside", LocalDate.of(
- 2015, 03, 7), 50, false);
- Excursion ex5 = new Excursion("Visit the old city", LocalDate.of(2015,
- 03, 9), 75, false);
- Excursion ex6 = new Excursion("Visit some ruins", LocalDate.of(2015,
- 05, 11), 45, false);
- Excursion ex7 = new Excursion("A day at spa",
- LocalDate.of(2015, 05, 12), 120, false);
- Excursion ex8 = new Excursion("Tour of the city", LocalDate.of(2015,
- 05, 13), 39.99, false);
- Excursion ex9 = new Excursion("A day with the queen", LocalDate.of(
- 2015, 05, 14), 185, true);
- Excursion ex10 = new Excursion("Meet the president", LocalDate.of(2015,
- 05, 15), 25, false);
- Excursion ex11 = new Excursion("Visit the volcano", LocalDate.of(2015,
- 05, 20), 220, true);
- ex1.addConference(c1);
- c1.addExcursion(ex1);
- ex2.addConference(c2);
- c2.addExcursion(ex2);
- ex3.addConference(c3);
- c3.addExcursion(ex3);
- ex4.addConference(c4);
- c4.addExcursion(ex4);
- ex5.addConference(c1);
- c1.addExcursion(ex5);
- ex6.addConference(c1);
- c1.addExcursion(ex6);
- ex7.addConference(c1);
- c1.addExcursion(ex7);
- ex8.addConference(c1);
- c1.addExcursion(ex8);
- ex9.addConference(c1);
- c1.addExcursion(ex9);
- ex10.addConference(c1);
- c1.addExcursion(ex10);
- ex11.addConference(c1);
- c1.addExcursion(ex11);
- ex1.addCompanion(comp1);
- ex1.addCompanion(comp2);
- ex1.addCompanion(comp3);
- ex1.addCompanion(comp4);
- ex1.addCompanion(comp5);
- ex2.addCompanion(comp1);
- ex2.addCompanion(comp2);
- ex2.addCompanion(comp3);
- ex3.addCompanion(comp4);
- ex3.addCompanion(comp5);
- ex3.addCompanion(comp6);
- ex3.addCompanion(comp7);
- ex4.addCompanion(comp1);
- ex4.addCompanion(comp2);
- ex5.addCompanion(comp3);
- ex5.addCompanion(comp4);
- ex5.addCompanion(comp5);
- ex6.addCompanion(comp6);
- ex6.addCompanion(comp7);
- ex7.addCompanion(comp1);
- ex8.addCompanion(comp2);
- ex8.addCompanion(comp3);
- ex9.addCompanion(comp4);
- ex10.addCompanion(comp5);
- ex11.addCompanion(comp6);
- ex11.addCompanion(comp7);
- comp1.addExcursion(ex1);
- comp2.addExcursion(ex1);
- comp3.addExcursion(ex1);
- comp4.addExcursion(ex1);
- comp5.addExcursion(ex1);
- comp6.addExcursion(ex1);
- comp7.addExcursion(ex1);
- comp1.addExcursion(ex2);
- comp2.addExcursion(ex2);
- comp3.addExcursion(ex2);
- comp4.addExcursion(ex3);
- comp5.addExcursion(ex3);
- comp6.addExcursion(ex3);
- comp7.addExcursion(ex3);
- comp1.addExcursion(ex4);
- comp2.addExcursion(ex4);
- comp3.addExcursion(ex5);
- comp4.addExcursion(ex5);
- comp5.addExcursion(ex5);
- comp6.addExcursion(ex6);
- comp7.addExcursion(ex6);
- comp1.addExcursion(ex7);
- comp2.addExcursion(ex8);
- comp3.addExcursion(ex8);
- comp4.addExcursion(ex9);
- comp5.addExcursion(ex10);
- comp6.addExcursion(ex11);
- comp7.addExcursion(ex11);
- Room room1 = new Room("Double", true, 660);
- Room room2 = new Room("Double", true, 789.99);
- Room room3 = new Room("Double", false, 645);
- Room room4 = new Room("Double", false, 478);
- Room room5 = new Room("Double", true, 879.99);
- Room room6 = new Room("Double", false, 500);
- Room room7 = new Room("Single", false, 450);
- Room room8 = new Room("Single", true, 420);
- h1.addRoom(room1);
- h1.addRoom(room2);
- h1.addRoom(room3);
- h2.addRoom(room4);
- h2.addRoom(room5);
- h3.addRoom(room6);
- h3.addRoom(room7);
- h3.addRoom(room8);
- room1.setHotel(h1);
- room2.setHotel(h1);
- room3.setHotel(h1);
- room4.setHotel(h2);
- room5.setHotel(h2);
- room6.setHotel(h3);
- room7.setHotel(h3);
- room8.setHotel(h3);
- Registration reg1 = new Registration(p1, true, true, room1, 2734);
- Registration reg2 = new Registration(p2, false, true, room2, 5676.45);
- Registration reg3 = new Registration(p3, true, true, room8, 874);
- Registration reg4 = new Registration(p4, false, true, room4, 3543.5);
- Registration reg5 = new Registration(p5, false, true, room3, 4367);
- Registration reg6 = new Registration(p6, true, true, room5, 5765);
- Registration reg7 = new Registration(p7, false, true, room7, 4354);
- Registration reg8 = new Registration(p8, true, true, room6, 3464);
- reg1.setParticipant(p1);
- reg2.setParticipant(p2);
- reg3.setParticipant(p3);
- reg4.setParticipant(p4);
- reg5.setParticipant(p5);
- reg6.setParticipant(p6);
- reg7.setParticipant(p7);
- reg8.setParticipant(p8);
- p1.addRegistration(reg1);
- p2.addRegistration(reg2);
- p3.addRegistration(reg3);
- p4.addRegistration(reg4);
- p5.addRegistration(reg5);
- p6.addRegistration(reg6);
- p7.addRegistration(reg7);
- p8.addRegistration(reg8);
- reg1.setConference(c4);
- reg2.setConference(c3);
- reg3.setConference(c2);
- reg4.setConference(c2);
- reg5.setConference(c1);
- reg6.setConference(c1);
- reg7.setConference(c1);
- reg8.setConference(c1);
- reg1.setCompanion(comp1);
- reg2.setCompanion(comp2);
- reg3.setCompanion(comp3);
- reg4.setCompanion(comp4);
- reg5.setCompanion(comp5);
- reg6.setCompanion(comp6);
- reg7.setCompanion(comp7);
- comp1.addRegistration(reg1);
- comp2.addRegistration(reg2);
- comp3.addRegistration(reg3);
- comp4.addRegistration(reg4);
- comp5.addRegistration(reg5);
- comp6.addRegistration(reg6);
- comp7.addRegistration(reg7);
- c1.addRegistrations(reg8);
- c1.addRegistrations(reg7);
- c1.addRegistrations(reg6);
- c1.addRegistrations(reg5);
- c2.addRegistrations(reg4);
- c2.addRegistrations(reg3);
- c3.addRegistrations(reg2);
- c4.addRegistrations(reg1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement