As a software engineer for a building contractor, you have been tasked with computerizing the building contractor’s business operations. The building contractor has many clients, each requiring a specific job to be carried out. In pricing each job, the materials used, the quantity of materials and the labour cost are considered. You have chosen the object-oriented approach in designing a suitable data management system.
Produce an object-oriented system with a Material class that represents any Material to be used for jobs, a class Job that details all the material required for a particular job and associated costs, and a class DataMgt that captures the lists of all Materials, all Jobs and presents the main system interaction of all system objects. The object-oriented system contains the following:
(1) A class Material containing
a. A private property descrip for the description or name of the material.
b. A private property unitWeight for the unit weight of the material.
c. A private property unitPrice for the price of each unit of material.
d. A constructor which accepts parameters.
e. Accessor methods for all private properties.
here is my code. Am I right
Is this the correct answer thank you. I am new and I need better ideas and better methods to code
Second, below are my comments.
Grand Mutondo wrote:Produce an object-oriented system with a Material class (...)
You don't have Material class. You do have material class. Java is case-sensitive.
Grand Mutondo wrote:(...) a class Job (...) and a class DataMgt (...)
You don't have those classes. I guess you are going to write them later.
Grand Mutondo wrote:A class Material containing (...) accessor methods for all private properties.
You don't have these.
Here are thoughts about your code:
* Indentation is as important as correct syntax.
* Accessor methods (also called "getters") are used to access the the private fields, not input data. In general, they look like this:
* Class names should start with an Upper Case Letter.
* You have a constructor with a comment saying it takes parameters, when it only sets defaults.
* The next constructor does take parameters, but it sets three variables that do nothing. These variables are gone as soon as the constructor is done.
Another thing you can do is write a constructor requiring parameters. That means you are telling the world that if you want an object of this class, you can have it, but you must pass certain information. So you want a constructor taking description weight and price. There are ways you can validate the input, but that is probably too complicated for you now. But you will have values. So you don't want a constructor which allows you to set the values to 0. So you don't want the no‑arguments constructor (unless your instructions tell you to). you should delete that no‑arguments constructor. Remember the more access there is into your object, the more opportunity there is for people to do something wrong with it.
(2) A class Job containing
a. A property descrip for the description or title of a job.
b. A property price for the total price of the job.
c. A property materials for storing the list of materials required for the job.
d. A constructor which accepts parameters.
e. A method addItem() that adds an item/material passed as a parameter to the list of materials required for the job.
f. A method calcPrice() that calculates the total price of a job.
g. A method getPrice() that returns the total price of a job.
(3) A class dataMgt containing
a. A property materialList for storing the list of Material objects.
b. A property jobList for storing the list of all Job objects.
c. A constructor that does not accept any parameters.
d. A method processJob() that accepts a job request from the user; processJob() then uses the job request information to calculate the total price of a job and then prints the appropriate information to a dialog box or to a console.
e. A main() method that creates a dataMgt object called dm1 and then invokes the method processJob() on the object dm1.
job class code
Material class code
and the Main class
You seem to have problems with capitalization. As was mentioned before, Java is case sensitive. Classes should start with an uppercase letter; variables and methods should start with a lowercase letter.
It's hard to say, but you seem to be mixing up method names and variable names. A method is always called with parentheses, even if it's void: myMethod().