Ruby Examples
This commit is contained in:
23
level7/65.rb
Executable file
23
level7/65.rb
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/ruby
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
=begin
|
||||
나이 증가 메서드
|
||||
=end
|
||||
|
||||
class Person
|
||||
attr_accessor :name, :age
|
||||
|
||||
def initialize(name, age)
|
||||
@name = name
|
||||
@age = age
|
||||
end
|
||||
|
||||
def grow_up
|
||||
@age += 1
|
||||
end
|
||||
end
|
||||
|
||||
charlie = Person.new("Charlie", 13)
|
||||
charlie.grow_up
|
||||
p charlie
|
||||
Reference in New Issue
Block a user