mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 07:10:42 -08:00
29 lines
520 B
Rust
29 lines
520 B
Rust
pub struct Disk {
|
|
pub size: u8,
|
|
}
|
|
|
|
impl Disk {
|
|
pub fn new(size: u8) -> Self {
|
|
Disk { size }
|
|
}
|
|
|
|
pub fn draw(&self) {
|
|
let draw_space = || {
|
|
let space_amount = (15 - self.size) / 2;
|
|
|
|
if space_amount > 0 {
|
|
for _ in 0..space_amount {
|
|
print!(" ");
|
|
}
|
|
}
|
|
};
|
|
|
|
draw_space();
|
|
for _ in 0..self.size {
|
|
print!("*");
|
|
}
|
|
draw_space();
|
|
print!(" ");
|
|
}
|
|
}
|