Tino APCS

Lab 1.2 Second House

In Lab 1.1 First House, you used the gpdraw library to draw a house all in the main method. This is fine when your house has only a few parts, but what if you wanted to have 6 windows, each with some customization? In that case, it would be nice if for each window, you could call the same method and pass different parameters. The focus of second house will be to create a house where the parts are drawn in customizable methods with parameters.

Example Houses:

Workflow

  1. For this lab, you should have only one class named in the format PX_LastName_FirstName_SecondHouse
  2. Declare your DrawingTool as a static variable above the main method so it is accessible throughout the class: static DrawingTool pen;
  3. Instantiate the DrawingTool at the beginning of the main method: pen = new DrawingTool(paper);
  4. Make sure you are just initializing the static field, rather than declaring a different local variable with the same name. If you get a null pointer exception when trying to call a method on your drawing tool in another function, it may be because you failed to instantiate the DrawingTool correctly.
  5. Each method you write for house parts must also be declared static:

    public static void drawWindow(int width, int height, ...)
         

  6. Pick one of the house parts you already generalized and create a separate method for that part.

  7. It's your choice whether you want to include (x, y) position in the method parameters or just move the pen before calling the method.
  8. Make each of your variables a parameter of your method
  9. Test your method by drawing multiple copies of that part with different locations, colors, size, etc
  10. For each generalized part of your house, instead of just having a section of the main method using variables, move that code into a method that takes parameters, where each variable is a parameter.

Lab Requirements

  1. You have at least two methods that draw a house part using parameters
  2. Your picture uses your methods to draw multiple versions of the parts with different properties
  3. Improve your overall house by adding more complexity and features

Remember, every lab should have a header in the format below at the top of your class:

/*
    Name:       (your name here)
    Date:       (submission date)
    Period:     (your period)

    Is this lab fully working?  (Yes/No)
    If not, explain:
    If resubmitting, explain:
*/

You must Sign In to submit to this assignment

Last modified: August 28, 2023

Back to Lab 1.1 First House

Dark Mode

Outline