diff --git a/.idea/misc.xml b/.idea/misc.xml
index 76830ba..a6db409 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -30,6 +30,8 @@
+
+
diff --git a/.idea/rust.iml b/.idea/rust.iml
index 0650e07..657a62e 100644
--- a/.idea/rust.iml
+++ b/.idea/rust.iml
@@ -122,6 +122,14 @@
+
+
+
+
+
+
+
+
@@ -141,6 +149,7 @@
+
@@ -150,6 +159,7 @@
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 1826468..5b7d892 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -15,10 +15,14 @@
-
+
-
-
+
+
+
+
+
+
@@ -36,10 +40,12 @@
ftoc
expensive_closure(intensity)
+ ordinals
f_to_c
expensive_result.value(intensity)
+ ORDINALS
@@ -48,7 +54,6 @@
@@ -127,17 +135,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -169,7 +166,7 @@
-
+
@@ -197,7 +194,7 @@
-
+
@@ -256,13 +253,13 @@
-
+
-
+
-
+
@@ -275,11 +272,11 @@
+
-
@@ -319,8 +316,8 @@
-
-
+
+
@@ -328,7 +325,7 @@
-
+
@@ -350,20 +347,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -772,8 +755,33 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/oop/Cargo.toml b/oop/Cargo.toml
new file mode 100644
index 0000000..cb76d42
--- /dev/null
+++ b/oop/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "oop"
+version = "0.1.0"
+authors = ["Timothy Warren "]
+edition = "2018"
+
+[dependencies]
diff --git a/oop/src/lib.rs b/oop/src/lib.rs
new file mode 100644
index 0000000..c6d8f42
--- /dev/null
+++ b/oop/src/lib.rs
@@ -0,0 +1,45 @@
+/// Example of encapsulation, as a
+/// requirement of Object Oriented Programming.
+///
+/// The list property is private, eg, encapsulated,
+/// while the object itself handles manipulation of
+/// the list property.
+pub struct AveragedCollection {
+ list: Vec,
+ average: f64,
+}
+
+impl AveragedCollection {
+ pub fn add(&mut self, value: i32) {
+ self.list.push(value);
+ self.update_average();
+ }
+
+ pub fn remove(&mut self) -> Option {
+ let result = self.list.pop();
+ match result {
+ Some(value) => {
+ self.update_average();
+ Some(value)
+ },
+ None => None,
+ }
+ }
+
+ pub fn average(&self) -> f64 {
+ self.average
+ }
+
+ fn update_average(&mut self) {
+ let total: i32 = self.list.iter().sum();
+ self.average = total as f64 / self.list.len() as f64;
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn it_works() {
+ assert_eq!(2 + 2, 4);
+ }
+}