WOD2: Creating a Rectangle class

So far we have created a Circle & Square class. Next we’ll create a Rectangle class.

Rx: <10 min Av: 10-20 min Sd: 20-30 min DNF: 31+ min

Instructions

  1. Write down your start time on your notecard.
  2. If you haven’t been following along in class, download the Shapes Project and import it into your workspace. Make sure to rename the project Shapes_uLogin.
  3. Right-click on your Shapes project and go to New > Class to create a Rectangle class. Go ahead and check the box for Eclipse to create a main method.
  4. Add 5 fields to this class: x, y, width, height, and color. Integers are recommended.
  5. Add 2 constructors:
    • Default constructor (no parameters)
    • Constructor with 5 parameters (one for each field)
  6. Add get & set methods for the width field.
  7. Test that your set & get width methods are working in main by:
    1. Creating a Rectangle variable & initializing it by calling one of the constructors
    2. Printing out your Rectangle variable’s width value
    3. Setting the width to a different value.
    4. Printing the new value by calling your get method.
  8. Run the program to verify your changes.
  9. Export your program by right-clicking on your project folder, and selecting Export > General > Archive File. Name the file Rectangle_uLogin.zip.
  10. Upload the file to the assignment page on canvas
  11. Write down your stop time on your notecard.