-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathExercise 10.8 (Completed)
90 lines (78 loc) · 2.33 KB
/
Exercise 10.8 (Completed)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
1. (Review) Define the following terms:
a. Attribute - define the properties of interest.
b. Behavior - define how the object reacts to its environment.
c. Class - is a programming language description of a model.
d. Identity - a name by whic it can be uniquely identified in a program.
e. Model - is a representation of a problem.
f. Object - is an instance of a class.
g. Object description - is a figure that contains the object, it's attrubutes and behaviors.
h. State - is used to refer to how the created object appears at any one moment.
i. Value - is assigned to an objects attrubutes and is an integer or string.
j. Operation - such as add, multiply, and divide are created methods to perform calucations.
2. (Practice) Classify each of the following as classes or objects:
a. Maple trees - class
b. Ford cars - class
c. My collie dog - object
d. The oak tree in your neighbor’s yard - object
e. Boeing 767 planes - class
f. Your Ford Taurus - object
g. Kitchen tables - class
h. Student desks - class
i. The chair you’re sitting on - object
3. (Practice) a. For each of the following, determine what attributes might be of interest to
someone buying the item:
i. A book
pages
title
Author
body
index
ii. A can of soda
temputure
size
soda type
iii. A pen
color
size
ink level
iv. An elevator
size
capacity
age
v. A car
type
model
year
weight
b. Do the attributes you used in Exercise 4a model an object or a class of objects?
model an object
4. (Practice) For each of the following, determine what behavior might be of interest to someone
buying the item.
a. A car
max speed
0 to 60 time
move
b. An elevator
rate of door closing
speed to top floor
ropes max load
5. (Practice) a. List five attributes for a character in a video game.
height
weight
eye color
hair type
skin tone
b. List five behaviors that a character in a video game should have.
[Add the following as the last exercise:]
move
speak
think
read
write
6. (Practice) a. List the attributes and behaviors of interest in a program that simulates dealing
a hand of playing cards. For this exercise, use any card game you’re familiar with.
Game: Black Jack
attributes: deck size, players, number of cards in hand
behaviors: move, deal, talk, sees, counts, reads
b. What attributes of cards wouldn’t be of interest for purposes of the simulation?
attributes: card size, card age, card text size