Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need a proper line to line code for both the questions with clear output guidence not the code from any chatgpt or github Lab

image text in transcribed
image text in transcribed
image text in transcribedi need a proper line to line code for both the questions with clear output guidence not the code from any chatgpt or github
Lab \#2 Question I Understanding Inheritance Implement a super class Person. Make two classes, Student and instructor, inherit from Person. A person has a name and a year of birth. A student has a major and an instructor has a salary. Write the class definitions, the constructors, and the methods tostring () and equals () for all classes. Supply a test program that test these classes and methods. In the test class, use your imaginations to create person objects, students objects and instructor objects. Print these objects and compare them. Please note that part of the output is shown below only Question II Design a class named Triangle that extends GeometricObject (as shown below). The class should contain the following three private double data fields: sidel, side2, side 3 with default values 1.0 to denote three sides of the triangle. In addition, the class should have the following constructors and methods: 1. A no-arg constructor that initializes all three sides to 0 . 2. A constructor that creates a triangle with the specified sidel, side2, and side3. 3. The setter methods for three data fields. 4. The getter methods for three data fields. 5. A method named getPerimeter( that returns the perimeter of this triangle. 6. A method named toString 0 that returns a string description for the triangle. Write a test program that does the following tasks: 1. Prompts the user to enter three sides of the triangle. The program creates a Triangle object with these sides. Prompt the user to enter a color and a Boolean value to indicate whether the triangle is filled. Use these two input values to set the data fields color and filled. Write a test program that does the folowing tasks: 1. Prompts the user to enter three sides of the triangle. The program creates a Triangle object with these sides. Prompt the user to enter a color and a Boolean value to indicate whether the triangle is filled. Use these two input values to set the data fields color and filled. 2. Invoke the Triangle object's getPerimeter() and toString( methods. public class GeometricObject \{ private String color = "white"; private boolean filled; private java.util.Date dateCreated; /** Construct a default geometric object */ public GeometricObject \{ dateCreated = new java.util. Date(); ) / Construct a geometric object with the specified color * and filled value */ public GeometricObject(String color, boolean filled) dateCreated = new java.util.Date (; this.color = color; this.filled = filled; ; /** Return color */ public String getColor() \{ return color; \} /** Set a new color */ public void setColor(String color) \{ this.color = color; ; /** Return filled. Since filled is boolean, its get method is named isFilled */ public boolean isFilledO \{ return filled; public String getColor() \{ return color; y /** Set a new color */ public void setColor(String color) this.color = color; y /** Return filled. Since filled is boolean, its get method is named isFilled */ public boolean isFilled O \{ return filled; y /** Set a new filled */ public void setFilled(boolean filled) \{ this.filled = filled; i. /** Get dateCreated */ public java.util.Date getDateCreated( ) \{ return dateCreated; \} /** Return a string representation of this object */ public String toString( \{ return "created on " + dateCreated + "incolor: "+ color + " and filled: " filled; y

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

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

=+4 What are non-union workers representations?

Answered: 1 week ago