Java
OOP GUIDES / WORK
Basic Objects – Instance variables –
Instance methods – Constructors – Encapsulation – Object arrays – Aggregation
SHORT ANSWER QUESTIONS
GUIDES / TASKS
Point class
|
-Intro to
instance variables
|
Solutions
|
Circle class
|
-Instance
variables
-Constructor
-Creating
objects (instances)
-Note: Used
in Lesson 11.36
|
Solutions
|
Card class
|
-Instance
variables
-Constructor
-Creating
objects (instances)
-Note: Used
in Lesson 11.36
|
Solutions
|
Dog class
|
-Intro to
instance variables
-Intro to
instance methods
-toString()
method
|
Solutions
|
Dice class
|
-Implementing
instance methods
-Using this
-toString()
method
-Note: Used
in Lesson 12.11
|
Solutions
|
Circle class 2
|
-Instance
variables
-Constructors
-Constructor
overloading
-Using
objects as parameters
-Note: Used
in Lesson 11.37
|
Solutions
|
SingleTable class
|
-Constructor
-Instance
method implementation
-Note: Used
in Lesson 12.11
|
Solutions
|
Dude class
|
-Analyzing
code
-Creating
objects
-Note: Used
in Lesson 11.38
|
Solutions
|
Circle class 3
|
-Adding
instance methods to a class
-Creating
objects
-Note: Used
in Lesson 11.38
|
Solutions
|
Card class 2
|
-Adding
instance methods to a class
-Creating
objects
-Note: Used
in Lesson 11.38
|
Solutions
|
RoundTable class
|
-Creating a
simple class
-Creating
objects
-Note: Used
in Lesson 11.38
|
Solutions
|
Card class 3
|
-Using
objects to create programs
-Note: Used
in Lesson 11.38
|
Solutions
|
BankAccount class
|
-Creating a
simple class
-Creating
objects
-Note: Used
in Lesson 11.39
|
Solutions
|
Counter class
|
-Creating a
simple class
-Creating
objects
-Note: Used
in Lesson 11.39
|
Solutions
|
Coin class
|
-Creating a
simple class
-Creating
objects
-Note: Used
in Lesson 11.39
|
Solutions
|
Rectangle class 1
|
-Code analysis,
-Instance variables
-Instance methods
|
Solutions
|
Rectangle class 2
|
-Constructors
-Constructor
overloading
-Constructor
chaining
|
Solutions
|
House class
|
-Instance
variables
-Instance
methods
-Constructors
-Using OOP
and NOOPDraw
-Note: Used
in Lesson 12.11
|
Solutions
|
Prism class
|
-Constructors
and Instance methods
-Note: Used
in Lesson 12.12D (Review)
|
Solutions
|
Pen class
|
-Class
Design
-Note: Used
in Lesson 12.12D (Review)
|
Solutions
|
Weapon & Warrior classes
(incomplete)
|
-Instance
variables
-Constructors
-Instance
methods
-Aggregation
-Note:
Formerly used in Lesson 12.1
|
Solutions
|
Rectangle class 3
|
-Intro to
Encapsulation
-Note: Used
in Lesson 11.40
|
Solutions
|
Lamp class
|
-Intro to
Encapsulation
-Note: Used
in Lesson 11.40
|
Solutions
|
Name class
|
-Encapsulation
-Immutable
class
-Class
diagrams
-Note: Used
in Lesson 12.12A
|
Solutions
|
LateSlip class
|
-Encapsulation
-Note: Used
in Lesson 12.12A
|
Solutions
|
Point classes
|
-Immutable classes
-Code analysis
|
Solutions
|
Weapon class
|
-Implementing
instance methods
-Code
analysis
-Encapsulation
-Using this
-Note: Used
in Lesson 11.40
|
Solutions
|
Spaceship class
|
-Encapsulation
-toString()
-Used in
Lesson 11.43T
|
Solutions
|
Date class
|
-Advanced
class creation
-Instance
methods
-Encapsulation
|
Solutions
|
Date class 2
(incomplete)
|
-Advanced
class creation
-Instance
methods
-Encapsulation
|
Solutions
|
Bottle class
|
-Advanced
class creation
-Encapsulation
-Advanced
method design
-Note: Used
in Lesson 12.12B
|
Solutions
|
Bottle class 2
|
-Object
arrays
-Note: Used
in Lesson 12.12B
|
Solutions
|
Bottle class 3
|
-Object
arrays
-Code
analysis
-Note: Used
in Lesson 12.12B
|
Solutions
|
Room class 1
|
-Encapsulation
-Note: Used
in Lesson 12.12B
|
Solutions
|
Room class 2
|
-Object
arrays
-Note: Used
in Lesson 12.12B
|
Solutions
|
House class 2
|
-Object
arrays
-Processing
object arrays
-Using OOP
and NOOPDraw
-Note: Used
in Lesson 12.12B
|
Solutions
|
Hand class
|
-Aggregation
(no encapsulation)
-Note: Used
in Lesson 11.41
|
Solutions
|
Line class
|
-Aggregation
(no encapsulation)
-Note: Used
in Lesson 11.41
|
Solutions
|
Line class 2
|
-Aggregation
-Encapsulation
-toString()
-Note: Used
in Lesson 11.41
|
Solutions
|
Point class 2
|
-Implementing
instance methods
-Calling
instance methods
-Processing
object arrays
-Note: Used
in Lesson 12.12D (Review)
|
Solutions
|
Employee class
|
-Aggregation
-Using
multiple classes
-Note: Used
in Lesson 12.12C
|
Solutions
|
Case class
|
-Aggregation
-Object
array as instance variable
-Encapsulation
-Note: Used
in Lesson 12.12C
|
Solutions
|
Grid class
|
-Object
arrays
-Aggregation
-Using
NOOPDraw
-Note: Used
in Game of Life project
|
Solutions
|
Grid class 2
|
-Object
arrays
-Aggregation
-Animation
with NOOPDraw
-Note: Used
in Game of Life project
|
Solutions
|
IDEAS TO CONSIDER ADDING
+++++
In Dog class,
or as Dog class 2, add a rollover and an age check. If too old, then dog doesn’t roll
over. This would show more use of
instance variables.
Similarly, perhaps a young dog barks a lot while an older dog might bark
once, or growl or not do anything.
+++++
Simple intro
class similar to Dog
public class
HardDrive
{
public void writeData()
{
System.out.println(“data is being
written”);
}
public void readData()
{
System.out.println(“data is being
read from hard drive”);
}
}
public class Computer
{
public static void main(String[]args)
{
HardDisk segate= new HardDisk();
segate.writedata();
}
}
+++++
Object array
idea.
Students get
a Point class and a Line class as starter code.
Students are
also given code to create a Point array.
Students are
to write a function that will get a point array and create a Line array where
the lines are the lines between each point including the line from the last
point to the first point.
Can also
write a function that will translate all points in an array.
+++++
Pass by
reference for objects
Pass by
reference for datafields (Security risk when datafields are references.)
+++++
Array as a
datafield. (String chooser problem
from AP 2016 test?) (Or, a Sequence
class that holds an array with a sequence.
It has a getNext() method and perhaps a hasNext() method. And a getAt() method. Also a getPrev() and hasPrev(). And just a getCurrent() method.
+++++
Point class
with Point() constructor that generates points within a certain distance of
origin. Create many and draw them
using NOOPDraw. Then include a
translate method that moves points to a more central location on the screen
to make out the shape of the circle.
+++++
Possibly do a
turtle graphics application using NOOPDraw?
+++++
Possible idea
Couple which
needs two Persons. Couple can
haveChild() which returns a new Person.
We can put all Persons in a family maybe? Arraylist?
|