Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Object-oriented Programming Question 1 (a) Define a service class called Employee that has 3 data members, id, name and department. The class has a constructor

image text in transcribedimage text in transcribed Object-oriented Programming

Question 1 (a) Define a service class called Employee that has 3 data members, id, name and department. The class has a constructor to initialize all data members through the constructor's parameters, getter and setter methods for all data members and a toString() method which returns a satring that contains all object's data members. (b) Write a main class to create one object from the above class and test all the method created in the class. Question 2 Define a programmer-defined class named Cuboid that contains 3 instance variables - length (I), width (w) and height (h) of a cuboid. The class also includes getter and setter methods for each instance variables and methods perimeter(), area() and volume() which return perimeter, total surface are and volume of the cuboid respectively. Write also 2 constructors for the class - one with no-arg and second with 3 arguments for all instance variables. Formula for: Perimeter=4(I+w+h)Totalsurfacearea=2(Iw+wh+hl)Volume=Iwh Write a main class that creates two Cuboid objects which values are obtained from user input. The program then display the perimeter, the total surface area and the volume of both objects. It also specifies that which object is bigger than the other object based on their volume

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

Students also viewed these Databases questions