2012-08-15 18:46:55 -07:00
|
|
|
struct cat {
|
2012-09-10 18:56:07 -07:00
|
|
|
priv mut meows : uint,
|
2012-03-26 09:59:59 -07:00
|
|
|
|
2012-09-06 19:40:15 -07:00
|
|
|
how_hungry : int,
|
2012-09-07 19:04:40 -07:00
|
|
|
}
|
2012-03-26 09:59:59 -07:00
|
|
|
|
2012-09-07 19:04:40 -07:00
|
|
|
impl cat {
|
2012-03-26 09:59:59 -07:00
|
|
|
fn play() {
|
2012-03-29 12:21:13 -07:00
|
|
|
self.meows += 1u;
|
2012-03-28 18:50:33 -07:00
|
|
|
self.nap();
|
2012-03-26 09:59:59 -07:00
|
|
|
}
|
2012-09-05 15:58:43 -07:00
|
|
|
}
|
|
|
|
|
2012-09-07 19:04:40 -07:00
|
|
|
priv impl cat {
|
|
|
|
fn nap() { for uint::range(1u, 10u) |_i| { }}
|
|
|
|
}
|
|
|
|
|
2012-09-05 15:58:43 -07:00
|
|
|
fn cat(in_x : uint, in_y : int) -> cat {
|
|
|
|
cat {
|
|
|
|
meows: in_x,
|
|
|
|
how_hungry: in_y
|
|
|
|
}
|
2012-03-26 09:59:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let nyan : cat = cat(52u, 99);
|
|
|
|
nyan.play();
|
|
|
|
}
|