Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Java
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;
    }
}


What I have tried:

Its what i need to do..
On the output i get NULL value why ?
Thanks for help!

Write a department representing a purchase invoice in a clothing store. The invoice should have the following fields: - The amount of the purchase - The identity of the purchaser - Object representing the employee who made the sale. For such an object, we will write a department with a full name, identity card and phone number. Next, you must write a department that represents the work board in that store. Three employees are supposed to work at the shop each day, and this department should describe who the workers will be each day. For each day, type a class, with the work board composed of an array of objects from that class.
Posted
Updated 26-May-18 5:18am
v2

1 solution

Quote:
On the output i get NULL value why ?

You gave us no useful information like which output is NULL, or where in code.
Part of your job is also to find and correct bugs. The debugger is the tool of choice to help you on this activity.
Note: Knowing the debugger is mandatory for every serious programmer.
-----
Your code do not behave the way you expect, and you don't understand why !

There is an almost universal solution: Run your code on debugger step by step, inspect variables.
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't know what your is supposed to do, it don't find bugs, it just help you to by showing you what is going on. When the code don't do what is expected, you are close to a bug.
To see what your code is doing: Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.
Debugger - Wikipedia, the free encyclopedia[^]
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html[^]
https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html[^]
The debugger is here to only show you what your code is doing and your task is to compare with what it should do.

PS: I didn't gave you better hint about your problem because I don't have Java on my PC.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900