This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
cs330_f2016:lab5 [2016/09/16 23:23] dcostello |
cs330_f2016:lab5 [2021/06/30 23:42] (current) |
||
---|---|---|---|
Line 8: | Line 8: | ||
====Preparation:==== | ====Preparation:==== | ||
- | For this lab, you should use Julia v.0.4. You may use the binary hosted in Dr. Wingate's home directory, at | + | For this lab, you should use at least Julia v.0.4. You may use the binary hosted in Dr. Wingate's home directory, at |
''/users/faculty/wingated/cs330/languages/julia-2e358ce975/bin'' | ''/users/faculty/wingated/cs330/languages/julia-2e358ce975/bin'' | ||
Line 41: | Line 41: | ||
end | end | ||
- | type Circ <: shape | + | type Circ <: Shape |
center::Position | center::Position | ||
radius::Real | radius::Real | ||
end | end | ||
- | type square <: shape | + | type Square <: Shape |
upper_left::Position | upper_left::Position | ||
length::Real | length::Real | ||
end | end | ||
- | type Rect <: shape | + | type Rect <: Shape |
upper_left::Position | upper_left::Position | ||
width::Real | width::Real | ||
Line 61: | Line 61: | ||
=== Area === | === Area === | ||
<code Julia> | <code Julia> | ||
- | function area(Shape) ... | + | function area(shape) ... |
</code> | </code> | ||
Returns the area of the given shape. | Returns the area of the given shape. | ||
Line 68: | Line 68: | ||
=== In_Shape=== | === In_Shape=== | ||
<code Julia> | <code Julia> | ||
- | function inside(shape::Shape, position::Position) ... | + | function in_shape(shape::Shape, position::Position) ... |
</code> | </code> | ||
Returns if the position is inside the shape. Assume standard math coordinates where y is positive going up. The bounds are inclusive. | Returns if the position is inside the shape. Assume standard math coordinates where y is positive going up. The bounds are inclusive. | ||
Line 77: | Line 77: | ||
type Pixel | type Pixel | ||
r::Real | r::Real | ||
- | b::Real | ||
g::Real | g::Real | ||
+ | b::Real | ||
end | end | ||
</code> | </code> | ||
Line 123: | Line 123: | ||
function average_age(tree) | function average_age(tree) | ||
</code> | </code> | ||
- | Calculates the average age of the people in the tree. Use this years date 2016. Unknowns do not count as people. | + | Calculates the average age of the people in the tree. Use this years date 2017. Unknowns do not count as people. |
=== tree map === | === tree map === | ||
Line 135: | Line 135: | ||
function add_last_name(name::AbstractString, tree) | function add_last_name(name::AbstractString, tree) | ||
</code> | </code> | ||
- | Appends name to the end of the name of each member of the tree. You should use tree_map. | + | Appends name to the end of the name of each member of the tree. You should use tree_map. You do not need to add a space in front of the name. |
Hint: Julia uses ''*'' for string concatenation. | Hint: Julia uses ''*'' for string concatenation. |