Builder design Pattern - correct answer ✔✔ A pattern used to create objects made from a
bunch of other objects.
Used when:
- You want to build an object made up from other objects
- You want the creation of these parts to be independent of the main object
- Hide the creation of the parts from the client so both aren't dependent
(The builder part knows the specifics and every other class knows nothing about the specifics
about what it else does)
MVC design pattern - correct answer ✔✔ The Model View Controller design pattern completely
separates the calculations and interface from each other.
Model: Data and Methods used to work with it. (the domain information that the user
manipulates)
View: The Interface (knows how to display the interface to the user)
Controller: Coordinates interactions between the View and Model (takes input from the user
and decides what to do)
What does the Model part of MVC do? - correct answer ✔✔ - Often enforces information
integrity
- For games, this means enforcing the rules
, 1. What does it need to do?
2. Error conditions?
How do you traverse through a two dimensional array? - correct answer ✔✔ // 4 rows and 10
columns
int [ ] [ ] a = new int [4] [10];
Looping through a 2D array:
• Nested for loop traversal
• Goes throw each row by row.
r = rows
c = columns
for (int r = 0; r < myArray.length; r++) {
for (int c = 0; c < my Array[0].length; c++) {
int current = myArray[r][c]);
}
}
inside the innerloop:
myArray[c][r] += 10; // add 10 to each item
Adapter Design Pattern - correct answer ✔✔ - Allows 2 incompatible interfaces to work
together
- Used when the client expects a (target) interface