95-733 Internet Technologies
Classes
#Classes
and constants must begin with
#an
uppercase character.
#Instance
variable begin with an "@" sign.
#The
constructor is named initialize
class
Student
def initialize(n = 5)
@course = Array.new(n)
end
def getCourse(i)
return
@course[i]
end
def setCourse(c,i)
@course[i] =
c
end
end
individual
= Student.new(3)
individual.setCourse("Chemistry",
0)
puts
individual.getCourse(0)
Output
======
Chemistry