Java ООП композиция arraylist
Main Class import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList<Employee> employeesList = new ArrayList<Employee>(); Employee n1 = new Employee("soiri", 88753, "09645324"); Employee n2 = new Employee("sofia", 42455, "09645324"); Employee n3 = new Employee("bolira", 678312, "09645324"); Employee n4 = new Employee("kobi", 342423, "09645324"); Employee n5 = new Employee("kestin", 3434, "09645324"); Employee n6 = new Employee("madrid", 88753, "09645324"); Employee n7 = new Employee("rob", 524622, "09645324"); Employee n8 = new Employee("sosi", 143432523, "09645324"); Employee n9 = new Employee("coli", 2525141, "09645324"); Employee n10 = new Employee("ban", 2525252, "09645324"); employeesList.add(n1); employeesList.add(n2); employeesList.add(n3); employeesList.add(n4); employeesList.add(n5); employeesList.add(n6); employeesList.add(n7); employeesList.add(n8); employeesList.add(n9); employeesList.add(n10); Invoice invoice = new Invoice(500,"David",n1); ArrayList<DayWorking> workingOfDay = new ArrayList<DayWorking>(); DayWorking d1 = new DayWorking(n1,n2,n3); DayWorking d2 = new DayWorking(n2,n4,n6); DayWorking d3 = new DayWorking(n7,n8,n9); DayWorking d4 = new DayWorking(n3,n1,n10); DayWorking d5 = new DayWorking(n5,n8,n9); DayWorking d6 = new DayWorking(n10,n5,n2); workingOfDay.add(d1); workingOfDay.add(d2); workingOfDay.add(d3); workingOfDay.add(d4); workingOfDay.add(d5); workingOfDay.add(d6); ArrayList<WorkSchedule> week = new ArrayList<WorkSchedule>(); WorkSchedule w1 = new WorkSchedule(d1); week.add(w1); invoice.printDetails(); w1.printWorking(); //week.printWorking(); //loop } } public class Employee { private String namePurchaseOrder; private int id; private String phoneNumber; public Employee() { } public Employee(String namePurchaseOrder, int id, String phoneNumber) { this.namePurchaseOrder = namePurchaseOrder; this.id = id; this.phoneNumber = phoneNumber; } public String getNamePurchaseOrder() { return this.namePurchaseOrder; } public void setNamePurchaseOrder(String namePurchaseOrder) { this.namePurchaseOrder = namePurchaseOrder; } public int getId() { return this.id; } public void setId(int id) { this.id = id; } public String getPhoneNumber() { return this.phoneNumber; } public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } } public class Invoice { private int price; private String clientName; private Employee seller; public Invoice () { } public Invoice(int price, String clientName, Employee seller) { this.price = price; this.clientName = clientName; this.seller = seller; } public int getPrice() { return price; } public void setPrice(int price) { this.price = price; } public String getClientName() { return clientName; } public void setClientName(String clientName) { this.clientName = clientName; } public Employee getSeller() { return seller; } public void setSeller(Employee seller) { this.seller = seller; } public void printDetails() { System.out.println("Price: "+ price); System.out.println("Client Name: "+ clientName); System.out.println("Seller: "+ seller); } } public class WorkSchedule { private DayWorking d1; private DayWorking d2; private DayWorking d3; private DayWorking d4; private DayWorking d5; private DayWorking d6; public WorkSchedule(DayWorking d1) { this.d1 = d1; } public WorkSchedule(DayWorking d1, DayWorking d2, DayWorking d3, DayWorking d4, DayWorking d5, DayWorking d6) { this.d1 = d1; this.d2 = d2; this.d3 = d3; this.d4 = d4; this.d5 = d5; this.d6 = d6; } public DayWorking getD1() { return d1; } public void setD1(DayWorking d1) { this.d1 = d1; } public DayWorking getD2() { return d2; } public void setD2(DayWorking d2) { this.d2 = d2; } public DayWorking getD3() { return d3; } public void setD3(DayWorking d3) { this.d3 = d3; } public DayWorking getD4() { return d4; } public void setD4(DayWorking d4) { this.d4 = d4; } public DayWorking getD5() { return d5; } public void setD5(DayWorking d5) { this.d5 = d5; } public DayWorking getD6() { return d6; } public void setD6(DayWorking d6) { this.d6 = d6; } public void printWorking() { System.out.println("The name of the Working monday: " + d1); System.out.println("The name of the Working sunday: " + d2); System.out.println("The name of the Working thursday: " + d3); System.out.println("The name of the Working tuesday: " + d4); System.out.println("The name of the Working wednesday: " + d5); System.out.println("The name of the Working saturday: " + d6); } } public class DayWorking { private Employee morning; private Employee noon; private Employee evening; public DayWorking() { } public DayWorking(Employee morning, Employee noon, Employee evening) { this.morning = morning; this.noon = noon; this.evening = evening; } public Employee getMorning() { return morning; } public void setMorning(Employee morning) { this.morning = morning; } public Employee getNoon() { return noon; } public void setNoon(Employee noon) { this.noon = noon; } public Employee getEvening() { return evening; } public void setEvening(Employee evening) { this.evening = evening; } }
Что я уже пробовал:
Это то, что мне нужно сделать..
На выходе я получаю нулевое значение почему ?
Спасибо за помощь!
Напишите отдел, представляющий счет-фактуру покупки в магазине одежды. Счет - фактура должен содержать следующие поля: - сумма покупки - личность покупателя-объект, представляющий сотрудника, совершившего продажу. Для такого объекта мы напишем отдел с полным названием, удостоверением личности и номером телефона. Затем вы должны написать отдел, который представляет рабочую доску в этом магазине. Каждый день в цехе должны работать три работника, и этот отдел должен описывать, кто будет работать каждый день. Для каждого дня введите класс с рабочей доской, состоящей из массива объектов из этого класса.