summaryrefslogtreecommitdiff
path: root/src/ship.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2018-02-23 01:10:14 -0600
committertom barrett <spalf0@gmail.com>2018-02-23 01:10:14 -0600
commit7798ebba1d8762e8b4c6eaf1efcd610fa030375a (patch)
treee5d01dfadf6fa8695c29f6ed4ba2a1c727ecd901 /src/ship.rs
parent839f8a7a260276973f41a2c5a6e9d138518d7072 (diff)
-found way to downcast and created new struct
Diffstat (limited to 'src/ship.rs')
-rw-r--r--src/ship.rs14
1 files changed, 11 insertions, 3 deletions
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;
}