Create a class named Rectangle. 1. There are two int instance variables: width and length. 2. Create three constructors.     a. Take two arguments from a client to the instance variables.     b. Take one argument from a client to the instance variables;         set it as a square instead of rectangle.     c. No-argument constructor.  Set up the way to take user information from keyboard. 3. Create 7 methods.     a. getWidth(): return width to caller.     b. getLength():  return length to caller.     c. setWidth(): take one argument to reset width.     d. setLength(): take one argument to reset length.     e. getArea(): calculate area of rectangle and return area to caller.     f. getPerimeter(): calculate perimeter of rectangle and return perimeter to caller.     g. toString(): return a String with the information about width, length, area, and perimter of the object to caller. II Create a class named Yard which inherits Rectangle. 1. There is one more double instance variable: unitPrice. 2. Create a constructor. 3. Create three methods.     a. enlarge(): take two arguments to increase the width and length.     b. getPay(): to calculate a payment for a yard work.         The way to calculate is sum of the followed               i.  unitPrice * area of the rectangle.              ii.  unitPrice * perimeter of the rectangle.     c. toString(): to return information about a yard work on unit price and total payment          and call super's toString to get retangle information to caller. III. Create a class name YardTest to have a main method to create objects and test your methods. Create an object of Yard with three arguments. Use toString concept to print information about the object you just created. Call enlarge method with an argument. Print the information again. Create another object of Yard with one argument only. Print information about this object. (Optional) Create the third object of Yard with two arguments.  Print information about the new object.( Optional)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I. Create a class named Rectangle.

1. There are two int instance variables: width and length.

2. Create three constructors.

    a. Take two arguments from a client to the instance variables.
    b. Take one argument from a client to the instance variables;
        set it as a square instead of rectangle.
    c. No-argument constructor.  Set up the way to take user information from keyboard.

3. Create 7 methods.

    a. getWidth(): return width to caller.
    b. getLength():  return length to caller.
    c. setWidth(): take one argument to reset width.
    d. setLength(): take one argument to reset length.
    e. getArea(): calculate area of rectangle and return area to caller.
    f. getPerimeter(): calculate perimeter of rectangle and return perimeter to caller.
    g. toString(): return a String with the information about width, length, area, and perimter of the object to caller.

II Create a class named Yard which inherits Rectangle.

1. There is one more double instance variable: unitPrice.

2. Create a constructor.

3. Create three methods.

    a. enlarge(): take two arguments to increase the width and length.
    b. getPay(): to calculate a payment for a yard work.
        The way to calculate is sum of the followed
              i.  unitPrice * area of the rectangle.
             ii.  unitPrice * perimeter of the rectangle.
    c. toString(): to return information about a yard work on unit price and total payment
         and call super's toString to get retangle information to caller.

III. Create a class name YardTest to have a main method to create objects and test your methods.

  • Create an object of Yard with three arguments.
  • Use toString concept to print information about the object you just created.
  • Call enlarge method with an argument.
  • Print the information again.
  • Create another object of Yard with one argument only. Print information about this object. (Optional)
  • Create the third object of Yard with two arguments.  Print information about the new object.( Optional)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 5 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY