Ms Gold
Lesson 10/5 - 10/7
Introduction to Object Oriented Programming
Lesson Plan 9 -
Mass Framework:
Standard 1:
Standard 2:
Standard from Technology/Engineering Standards for a Full First-Year Course in Grades 9 or 10
Learning Objective:
Learning Experience:
Objective is using objects as black boxes
Test
* go over Black box concept
r2.9 Write a Java statement that initialize two variables square1 and square2 to refer to the same square with the center(20,20,40,40)
Rectangle square1 = new Rectangle square(20,20,40,40);
Rectangle square2 = square1;
R2.10 - write a Java statement that initialize a string message with "Hello" and then change it to "HELLO" Us the toUpperCase method
String message = "Hello";
message = message.toUpperCase();
R2.11
String message = "Hello";
message = message.replace("H", "h");
R2.12
a. new Rectangle is missing
b. Rectangle(5, 10, 15, 20) does not refer to an object. The corrected version should be:
double width = (new Rectangle(5, 10, 15, 20)).getWidth();
c. r has not been initialized; it does not refer to any object.
d. The method translate takes two integer arguments, not a string argument.
R2.13 Name 2 accessor and 2 mutators of the Rectangle class
Possible answers are:
Accessor: getWidth(), getHeight()
Mutator: translate(int, int), add(int, int)
R2.14What is the result of the following operationRectangle box = new Rectangle(5,10, 20,30);
box.add(0,0)
The rectangle to which the variable box refers has the following coordinates:
x = 0;
y = 0;
width = 25;
height = 40;
R2.15 difference between a console app and a graphical app
Console applications provide text-only interfaces and cannot display any drawings/figures (except ASCII art). Graphical applications are more user friendly and can display drawings inside frames (windows).
R2.16
The Swing toolkit calls the paintComponent method whenever the component needs to be repainted. For example, it is called when the window is shown for the first time, when it is resized, or when it is shown again after it was hidden.
R2.17
The designers of Java did not want to inconvenience those programmers who had produced programs that used simple graphics from the Graphics class after they developed the newer, more powerful Graphics2D class, so they did not change the parameter of the paintComponent method to Graphics2D.
R2.18
The purpose of a graphics context is to store the programmer choices for colors, fonts, and so on, and to draw and fill shapes.
R2.19
The paintCompoment method of the component class produces a drawing, while the main method of the viewer class constructs a frame and a component, adds the component to the frame, and makes the frame visible.
R2.20
You specify a text color simply by calling the setColor method of the graphics context before calling the drawString method.
*more on translate - go over p2.4 and can start with how to implement a public interface.