Tino APCS

Attributes

Our goal is to create a Window class that can be used to create many different window objects from the same blueprint.

public class Window {

    // Attributes

    // Constructors

    // Methods
}


Consider the window shown below:

What attributes describe this window? Here are some possibilities:

  • x-position
  • y-position
  • width
  • height
  • interior color
  • frame color
  • line thickness
  • number of panels

If we want to add these attributes to our Window class, we need to declare them as variables that can store the right kind of information. Here are the data types you will need for now. See Lesson 3 for a complete list.

Data type What it represents Examples
int an integer int x = 5; int y = -108;
double a floating-point number double pi = 3.14; double z = -1000; double w = 0.0001; Note that a double can also hold an integer.
some class an object of that class DrawingTool pen; SketchPad pad; Color c; String str;


Let's use these data types to add some attributes to our Window class.

public class Window {

    // Attributes
    int xPos;
    int yPos;
    int width;
    int height;
    Color frameColor;
    Color interiorColor;

    // Constructors

    // Methods
}

Last modified: December 12, 2022

Back to Class Structure

Dark Mode

Outline