Foundations of CS Unit 2 GRAPHICS KD Labs 03-08

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/14

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

15 Terms

1
New cards

Data Fields

Used to store data, usually within an object. 

  • Defines state of the object

  • Declared within class body with an ACCESS modifier, a data type, and name

  • Variables declared WITHIN a class but NOT A METHOD

Define the characteristics of an object created from the class. 

Ex) public class Bug {

private int myX;

private int myY;  //myX and myY store values and give characteristics of Bug object

}

2
New cards

Constructors

A special type of data field that initializes new objects of a class. Sets initial values of data fields.

Ex)public Bug() {
myX = 0;
myY = 0;
}
public Bug(int x, int y) { // accepts arguments for int x and int y, defined above
myX = x;
myY = y;
}

3
New cards

Buffer

A temporary storage area for drawing the image (off-screen) which is then “pasted” onto the screen at the end. 

Eliminates images that flicker in animation, where there are lots of drawing commands.

4
New cards

Instance Variables

Variables belonging to a specific object or INSTANCE of a class. Makes copies so each object has it’s own copy. Declared in the class but not a part of the methods, constructors, or blocks.

Represent the state or attribute of an object. They define the characteristics of an object.

Ex) Class car { //class name

String color //instance variable

int speed; }

5
New cards

Final

Means it is marked CONSTANT. It cannot be changed unless it is deleted.

6
New cards

What are fields in Java?

Fields are variables created and used by a class. They represent data or attributes associated with the class.

Declared within a class but outside of methods. 

Ex) private field, public field 

7
New cards

What does a void method do?

It does not return a value but takes action. 

8
New cards

Instance Method

Where the individual objects own the method. No static keyword is found, and there may be multiple unique copies owned by each object.

9
New cards

Class (static) Method

Add powers to the class, not to the objects. Remain with the class and do not get duplicated in each object. There is exactly one copy of a static method which is owned by the class. 

10
New cards

Boolean 

Returns a True or False value.

11
New cards

Integer

Returns an integer value. (Including 0)

12
New cards

Double

Returns a decimal value.

13
New cards

Modifier Methods

Change data in an object’s fields. AKA “setter” methods, usually begin with “set”. 

Ex) 

smidge.setColor(Color.YELLOW);    // tells Smidge to set it’s color to YELLOW

smidge.setThickness(10);    // tells Smidge to set it’s thickness to 10 

14
New cards

Accessor Methods

Retrieve values of private fields outside the class without direct manipulation of the data inside. Controls and asks “who can access this class?”. 

Get data from the object’s fields. AKA “getter” methods, usually begin with “get”. 

ALWAYS return a VALUE (periodt)

Ex) 

getColor()

getImage()

getX()   // or getY() in Bug’s case

15
New cards