From 7798ebba1d8762e8b4c6eaf1efcd610fa030375a Mon Sep 17 00:00:00 2001 From: tom barrett Date: Fri, 23 Feb 2018 01:10:14 -0600 Subject: -found way to downcast and created new struct --- src/ship.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/ship.rs') diff --git a/src/ship.rs b/src/ship.rs index 715f019..30a27fb 100644 --- a/src/ship.rs +++ b/src/ship.rs @@ -5,6 +5,13 @@ extern crate serde_json; pub struct Ship { name : String, location : (isize, isize, isize), + r : f64, +} + +impl Ship { + pub fn range(&self) -> f64 { + self.r + } } impl Mass for Ship { @@ -12,18 +19,19 @@ impl Mass for Ship { Ship { name : String::from(name), location : location, + r : 10.0, } } - fn get_name(&self) -> &String { + fn name(&self) -> &String { &self.name } - fn get_location(&self) -> (isize, isize, isize) { + fn location(&self) -> (isize, isize, isize) { self.location } - fn give_location(&mut self, location : (isize, isize, isize)) { + fn set_location(&mut self, location : (isize, isize, isize)) { self.location = location; } -- cgit v1.2.3