Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class called Worker. Make sure you write a description of your new Class in the comments, with your name as author and

 

image

Create a class called Worker. Make sure you write a description of your new Class in the comments, with your name as author and date as the last date you worked on this exercise. Add definitions for the following fields: A name field of type String An workerld field of type int A wage field of type double A fullTime field of type boolean Write a constructor for your Worker class that takes four parameters - the first of type String called myName, the second of type int called myWorkerld, the third of type double called myWage, and the fourth of type boolean called isFullTime. Set the initial values of the corresponding fields using the constructor. Write an accessor method called getName that returns the value of the name field. 2 Write a mutator method called setWorkerld that takes a single parameter of type int and sets the value of the employeeld field. Work out what other accessor and mutator methods would be useful for this Class and add them. You should be able to get and set all fields in the Class. Write a method called printDetails, which prints out all the details of an Worker object. You must take into account the fullTime status and print a line saying either that the employee is fulltime or the employee is not fulltime. For example, if: The name field holds the value "John Smith" The workerld field holds the value 123456 The wage field holds the value 25.40 . The fullTime field holds the value false Then the printDetails method would print out the following: The name of the worker is John Smith. The worker id is 123456. The wage of the worker is $25.40 per hour. The employee is not full-time. If the full-time field holds the value True, then the printDetails method would print out the following: The name of the worker is John Smith. The worker id is 123456. The wage of the worker is $25.40 per hour. The worker is full-time. Please Note: In the above examples, the name, workerld, wage and whether the worker is full-time or not (in blue) will change based on the values the fields hold. However, you must print the remainder of the statements exactly as in the above examples.

Step by Step Solution

3.47 Rating (160 Votes )

There are 3 Steps involved in it

Step: 1

java Description This class represents a worker with basic information such as name worker ID wage a... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions