Starting from:
$30

$24

Classes and Objects Lab 07 Solved

    a. Create a new project Lab07.

Create a class ​Project​with the following properties and the methods:

        ◦ Constant Data Members:

            ▪ TAX​: tax rate to be applied to project (19%)

            ▪ OVERHEAD​: project overhead 30000TL
            ▪ EMP_HOURS_WEEK​: number of hours employee works per week (40)

        ◦ Static Data Members:

            ▪ projectCounter​: initial value is 1000 and counts the number of projects created.

        ◦ Instance Data Members:

            ▪ projectId​: stores the id of the project (example: “2019-1000”)

            ▪ projectName​: stores the name of the project.
            ▪ projectType​: stores the character representing the project type.
            ▪ personHours​: stores the estimated person hours for the project.
            ▪ ratePerHour​: stores the standard rate per person hour.
            ▪ projectWeeks​: stores the estimated duration of the project in weeks.

        ◦ Methods:

            ▪ Constructor:

                • Takes the project name, person hours, rate per hour and the project weeks as parameters.

                • Initializes the project name.

                • Uses the set methods to initialize personHours, ratePerHour, projectType, projectWeeks, projectId.

            ▪ Accessor methods:

                • getProjectId​, get​ProjectName​, get​ProjectType​, get​PersonHours​, get​RatePerHour​, get​ProjectWeeks​.

            ▪ Mutator methods:

                • setProjectName ​- sets the project name to the value passed as parameter.
                • setPersonHours - sets ​personHours to value passed as parameter, if value is positive, zero if negative.
            ▪ setRatePerHour ​- sets ​ratePerHour to value passed as parameter, if value is positive, zero if negative.
            ▪ setProjectWeeks- ​sets ​projectWeeks to value passed as parameter, if value is positive, zero if negative.

            ▪ setProjectId ​- private method that sets the project id using the year (2019) plus the current project counter (example: 2019-1005 if 5 projects have been created)

            ▪ setProjectType ​- type is determined by the calculated project cost. If the cost is over 500000 it is a (​m​)ajor project, between 100000 and 500000 it is an (​a​)dvanced project, between 0 and 100000, (​s​)tandard project, and 0 or less, the project is​ (i)​nactive.

        ◦ Other methods:

            ▪ deactivateProject​(): sets the project to​ (i)​nactive.

            ▪ calculateProjectCost​(): calculates and returns the cost of the project. Cost is calculated by summing the human resource cost (personHours multiplied by ratePerHour), and the project overhead, and increasing by the tax rate. Note: if the cost before overhead is less than 20000, the OVERHEAD is not added.

            ▪ calculatePersonResources​(): calculates and returns the number of employees required for the project, using the personHours, projectWeeks. Assume each employee is contracted for 40 hours each week (​EMP_HOURS_WEEK​).

            ▪ compareProjects​(): instance method that takes a Project as a parameter, and compares the Projects. If the target object has a higher cost, returns 1, lower cost returns -1, same cost returns 0.

            ▪ toString​(): returns a String representation of a project. See sample output for format details. Active and inactive projects will display differently as shown below.


    b. Create an application class ​ProjectApp​which does the following:
    • Create 3 Projects

    • Display the projects.

    • Compare the projects using the appropriate method and display the result.

    • Update the projects:

        ◦ Change their personWeeks and ratePerHour.

        ◦ Update the projectType.

        ◦ Deactivate one of the projects.

        ◦ Display the updated projects.
Sample Output:

Project Name: ArcTech Business Solution

Project ID: 2019-1000

Project Type: m

Team Size: 6

Estimated Project Cost: 2983092.0

Project Name: SunMarkets POS Implementation

Project ID: 2019-1001

Project Type: a

Team Size: 1

Estimated Project Cost: 155652.0



-------INACTIVE PROJECT------

Project Name: HealthTech Hospital

Project ID: 2019-1002

Project with greater cost:

Project Name: ArcTech Business Solution

Project ID: 2019-1000

Project Type: m

Team Size: 6

Estimated Project Cost: 2983092.0

More products