working on draw methods
This commit is contained in:
Uğur Küpeli
2022-05-05 02:00:33 +03:00
parent 9a582ed0d9
commit b86c30e89c
6 changed files with 121 additions and 0 deletions

27
90_Tower/rust/src/disk.rs Normal file
View File

@@ -0,0 +1,27 @@
pub struct Disk {
size: u8,
}
impl Disk {
pub fn new(size: u8) -> Self {
Disk { size }
}
pub fn draw(&self) {
let space_amount = (15 - self.size) / 2;
let draw_space = || {
if space_amount > 0 {
for _ in 0..space_amount {
print!(" ");
}
}
};
draw_space();
for _ in 0..self.size {
print!("*");
}
draw_space();
}
}