во имя спасения
#not finished#
##### main
$:.unshift(File.dirname(__FILE__))
require 'man'
require 'savior'
mann= Man.new
mann.pr_status
kil=Savior.new
kil.killman(mann)
mann.pr_status
#####world
$:.unshift(File.dirname(__FILE__))
require 'man'
class World
def initialize m
@people= [m]
end
def addPeople
if @people.length<2
@people[@people.length] = Man.new MALE
end
end
def colp
@people.length
end
def flm
m = @people.detect{|e| e.pr_status == LIVE}
m
end
def killman
@people[@people.length-1].kill
end
end
#####man
MALE = true
FEMALE = false
LIVE = true
DEAD =false
class Man
def initialize s
@status=LIVE
@sex=s
end
def kill
@status=DEAD
end
def pr_status
@status
end
end
#####savior
$:.unshift(File.dirname(__FILE__))
require 'man'
require 'world'
class Savior
def killman m
m.kill
end
def findLivep w
if w.flm != 0
m = w.flm
m.kill
end
end
end
sv= Savior.new
mn= Man.new MALE
wr= World.new mn
print wr.flm
print "\n"
print wr.colp.to_s + "\n"
sv.findLivep wr
print wr.colp
wr.addPeople
print wr.colp.to_s + "\n"
print wr.flm
|
Категория: programm_Psyhoz(); | Добавил: mdErrDX5341 (15.03.2011)
|
Просмотров: 549
| Рейтинг: 0.0/0 |
Добавлять комментарии могут только зарегистрированные пользователи. [ Регистрация | Вход ]
|