Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Q1: Perform following tasks:

Task_A
Create a class Employee with following constraints in mind:

- Declare two data members named firstName and lastName of string type.
- Implement a parameterized constructor, which will take firstName and lastName of an employee and initialized the respective data members.
- Implement a print function that displays the complete name (firstNamelastName) of an Employee.
 
Task_B
Test the working of your created Employee class with the help of a main program.

Task_C
Create a class HourlyWorker which inherits from Employee class publically with following constraints in mind:

- Declare two data members named wage and hours of double type with private access.
- Implement a parameterized constructor, which initializes all the data members of HourlyWorker class.
- Implement a getPay function that calculate and return the salary (hours * wage) of particularHourlyWorker employee.
- Implement a print function that displays the complete name and salary of a particular employee.

Task_B
Test the working of your created HourlyWorker class with the help of a main program.

Q2: Implement the following class hierarchy, the inheritance access level should be protected for Reptile, Bird and Mammal on the other hand it should be private for Snake, Parrot and Horse classes.

604_Figure.jpg

Task _A
Add a protected data member named id of integer type to Animal class.

Task_B
Add get/set methods for id data member in Animal class with public access.

Task_C
Add a default constructor to each of the above created class. The constructor should initialize the id data member of Animal, Reptile, Bird and Mammal, to 0, 1, 2 and 3 respectively also it display a message "(class Name)'s default constructor".

Task_D
Add a parameterized constructor to each of the above created class. The constructor should initialize the id data member of Animal, Reptile, Bird and Mammal, to the specified id passed to the constructor also it display a message"(class Name)'s default constructor". The parameterized constructor should call its base class parameterized constructor to initialize any data member inherited from the base class.

Task_F
Add a getFamily method to Snake, Parrot and Horse classes, this method must return the id of a particular animal's family where it belongs to.

Task_G
Add a tellAboutSelf method to Animal class with public access. The method displays the name of each objects class where it belongs to.

Task_H
Override the tellAboutSelf in all the sub-leaving classes of Animal with the same functionality as in Animal class.

Task_I
Add a speak method to Animal class and override it in each of the sub-leaving classes. The Animal, Reptile, Bird, Mammal, Snake, Parrot and Horse can speak by printing a message "I am Animal, I cant speak...", "Family of Reptiles..." "Family of Birds...", "Family of Mammals...", "Shhh....", "Trrrr...." and "Hurrrrr..." respectively.

Task_J

Write down your main method and instantiate object of each class created above, call tellAboutSelf, speak and getFamily methods for each of the created object.1. Create a class that intimates part of the functionality of the basic data type int, call the class Integer. The only data in the class is an int variable. Include constructors to initialize an Int to 0, to initialize it to an int value, to intialize it to Integer value, to get/set its value, to display it and to return the addition, Subtraction, multiplication and division of two Integer values.
Embed your class definition in a test program.

2. Define a class called Month that in an abstract datatype for a month. Your class will have one member variable of type int to represent a month (1 for January, 2 for February, and so forth). Include all the following member functions: a constructor to set the month using the first three letters in the name of the month as three arguments, a constructorto set the month using an integer as an argument (1 for January, 2 for February, and so forth), a default constructor, an input function as the first three letters in the name of the month, an output function that outputs the month as an integer, an output function that outputs the month as the first three letters in the name of the month, and a member function that returns the next month as a value type Month.

Embed your class definition in a test program.

3. Define a class for a type called CounterType. An object of this type is used to count things, so it records a count that is a nonnegative whole number. Include a defualt constructor that sets the counter to zero and a constructor with one argument that sets the counter to the value specified by its arguments. Include member functions to increase the count by one and to decrease the count by one. Make sure that no member function allows the value of the counter to become negative. Also, include a member function that returns the current count value and one that outputs the count.

In your test program, increment your counter to 10 and then decrement down to 5 and display its values after each step.

Java, Programming

  • Category:- Java
  • Reference No.:- M92287574
  • Price:- $150

Guranteed 48 Hours Delivery, In Price:- $150

Have any Question?


Related Questions in Java

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As