Define a class named Point containing: - Two private instance variables x and y of type int. - A full parametrized const

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Define a class named Point containing: - Two private instance variables x and y of type int. - A full parametrized const

Post by answerhappygod »

Define a class named Point containing: - Two private instance
variables x and y of type int. - A full parametrized constructor -
Getters for all instance variables Define an abstract class named
Shape containing: - An instance variable named S of type Point. - A
full parametrized constructor - A method named getS that returns
the value of instance variable s. - An abstract method named Area
that has a return type double. Define an interface named Printable
containing a method print without parameters and returning void.
Define a class named Rectangle which is extended from class Shape,
implements the interface printable and containing: - Three instance
variables named Length, Width of type int and an instance variable
named D of type Point. - A constructor with two parameters of type
Point which initializes all the instance variables. In addition,
initlize the rectangle’s length with absoulate value of difference
between x’s valuse of S and D. Initliaze the rectangle’s width with
absoulate value of difference between y’s valuse of S and D. - An
overridden method named Area which returns the calculated area of
the rectangle. - An overridden method named print which print the
pattern of a rectangle using the ‘*’ character according to the
length and the width. Define a class named Line which implements
the interface printable and containing: - Two instance variables
named start and end of type Point. - A constructor with two
parameters of type Point which initializes all the instance
variables. - A method getLength returning the length of a line (The
distance between start and end). 𝒍𝒆𝒏𝒈𝒕𝒉 = √(𝒆𝒏𝒅. 𝒙 − 𝒔𝒕𝒂𝒓𝒕. 𝒙) 𝟐 +
(𝒆𝒏𝒅. 𝒚 − 𝒔𝒕𝒂𝒓𝒕. 𝒚) 𝟐 - An overridden method named print which
print the pattern of a line using the ‘*’ character according to
the length of the line. Define a class named Text which implements
the interface printable and containing: - One instance variables
named Content of type String. - A full parametrized constructor. -
An overridden method named print which print the text. Define a
class named TestDemo contains the main method and has the following
1) Two objects of Point. 2) An array of Printable that has 3
objects of type Line, Rectangle, and Text. 3) Initialize all
objects with data and call Print method of all of them using
enhanced for
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply