Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make a LandTract class with the following fields: LandTract is a rectangle. * length - an int containing the tract's length * width - an

Make a LandTract class with the following fields: LandTract is a

rectangle.

* length - an int containing the tract's length

* width - an int containing the tract's width

The class should have a constructor with two arguments length and width and assign these to

the class variables.

Now define a Copy Constructor: The constructor that you will write will be a copy constructor

that uses the parameter LandTract object to make a duplicate LandTract object, by copying the

value of each instance variable (length and width) from the parameter object to the the new copy

object.

You also need to define the following methods:

equals - takes another LandTract object as a parameter and returns a boolean (true or false)

saying whether or not the two tracts have the same dimensions (length and width).

Compare the length and width of the tract given as parameter to the equals method with the

length and width of the other LandTract object.

toString - returns a String with details about the LandTract object in the format:

LandTract object has a length of 30 and width of 40

(If, for example, the LandTract object had a length of 30 and a width of 40.)

Write a separate demo class that asks the user to enter the dimensions for the two tracts of land

using Scanner object. Then, create another LandTract object as a copy of the first LandTract

object. It should print the output of two tracts' using the toString method, and should also print a

statement stating whether or not the tracts have equal dimensions.

(If the tracts have the same dimensions, print, "The two tracts have the same size." Otherwise,

print, "The two tracts do not have the same size.")

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

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions

Question

2-1. What are six characteristics of effective teams? [LO-1]

Answered: 1 week ago

Question

2-5. What are the three main types of active listening? [LO-4]

Answered: 1 week ago