Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Java class, using a separate .Java file, for any one business object by

ID: 3625243 • Letter: C

Question

Create a Java class, using a separate .Java file, for any one business object by adhering to the following requirements:
1. Justify, using a few sentences, why your choice may be considered a business object and why it is appropriate for this assignment.
2. Identify at least FOUR unique attributes for the business object you selected. Ensure that they are of different Java data types (int, String, etc.). Justify your choices.
3. Create GET (retrieve) and SET (store) methods for each of the FOUR attributes you selected for the object.
Create a Test class that will make use of the business object class you created. Adhere to the following requirements:
1. Create an instance of the business object.
2. Obtain data from the user for all FOUR attributes of the business object.
3. Display values of the FOUR attributes for the user.

Explanation / Answer

//Please make sure that you understand the code that is being written here, it is a template

// you must modify it to fit the needs of the assignment as it is somewhat generic as is.

//It will compile and run, you just need to import ArrayList

public class Business {
    // Note this is just a template to be followed, should be very easy to
    // modify to suit your needs, you

    // may wish to change the attributes for the given situation.

    /*
    * String that contains the name of the business, a neccessity for every
    * business
    */

    public String businessName = null;

    /*
    *
    * Float that contains the overall worth of the company, every company has a
    * net worth
    */

    public float netWorth = 0;

    /*
    * ArrayList of Strings that holds the names of the employees, you may want
    * to change this to take in an
    *
    * employee object if you made your own employee class
    */

    public ArrayList<String> employees = null;

    /*
    *
    * Integer which shows the branch number of the business if it is a chain
    */

    public int branchNum = 0;

    /**
    * Business constructor
    * @param businessName
    * @param netWorth
    * @param employees
    * @param branchNum
    */

    public Business(String businessName, float netWorth,
            ArrayList<String> employees, int branchNum) {

        this.businessName = businessName;

        this.netWorth = netWorth;

        this.employees = employees;

        this.branchNum = branchNum;

    }// end business()
   
    /**
    * gets businessName
    * @return businessName
    */
    public String getBusinessName() {

        return businessName;

    }// end getBusinessName()

    /**
    * Gets net worth
    * @return netWorth
    */
    public float getNetWorth() {

        return netWorth;

    }// end getNetWorth()

    /**
    * Gets Employees
    * @return employees
    */
    public ArrayList<String> getEmployees() {

        return employees;

    }// end getEmployees()

    /**
    * Gets branchNum
    * @return branchNum
    */
    public int getBranchNum() {

        return branchNum;

    }// end getBranchNum()

    /**
    * Sets the busienss name
    * @param businessName
    */
    public void setBusinessName(String businessName) {

        this.businessName = businessName;

    }// end setBusinessName()

    /**
    * sets the netWorth
    * @param netWorth
    */
    public void setNetWorth(float netWorth) {

        this.netWorth = netWorth;

    }// end setNetWorth()

    /**
    * Sets the ArrayList of employees
    * @param employees
    */
    public void setEmployees(ArrayList<String> employees) {

        this.employees = employees;

    }// end setEmployees()

    /**
    * Sets the number of this particular branch
    * @param branchNum
    */
    public void setBranchNum(int branchNum) {

        this.branchNum = branchNum;

    }// end setBranchNum

}// end class Business

//Below is the test file

public class Driver {
   
    public static void main(String[] args){
        ArrayList<String> employees = new ArrayList<String>();
        employees.add("myself");
        Business myBusiness = new Business("My Business", 50000,employees,1);
       
        System.out.println("Business name: "+myBusiness.getBusinessName());
        System.out.println("Business Net Worth: "+myBusiness.getNetWorth());
        System.out.println("Employees that work here:");
       
        for(int i = 0; i<myBusiness.getEmployees().size(); i++){
            myBusiness.getEmployees().get(i);
        }
       
        System.out.println("Branch number: "+ myBusiness.getBranchNum());
       
       
    }//end main

}//end Driver()