Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write code for Employee class. Assume the following code is given. class Employee ( private int id; private String name; private int age: //

Write code for Employee class. Assume the following code is given. class Employee ( private int id; private

Write code for Employee class. Assume the following code is given. class Employee ( private int id; private String name; private int age: // employee id // employee name // employee age public int getAge() { return age; } // return age // In (a) and (b) below, you need to write 2 methods // for the Employee class here (a) Write a constructor method with no input arguments for the Employee class. Set the default id to 0, the default name to "Unknown", the default age to 1. Show the method header clearly. // write your code here (b) Write the set() method for the Employee class (see header below); set id to newID, name to new Name, age to newAge. You must check that newAge is > 0. If newAge is not in the correct range, print an error message and return immediately, without changing any of the member variables of the Employee object. void set(int newID, String newName, int newAge) // your code go here 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

The Below is the code for the Employee class with the requested constructor and set method pub... 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_2

Step: 3

blur-text-image_3

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 An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

What is meant by Career Planning and development ?

Answered: 1 week ago

Question

What are Fringe Benefits ? List out some.

Answered: 1 week ago

Question

Graph one period of each function. y = 4 cos x

Answered: 1 week ago

Question

5. Make decisions about revealing the identity of participants.

Answered: 1 week ago

Question

4. Write a description about how the data were collected.

Answered: 1 week ago