exercises

Log | Files | Refs | README

calculator.rs (492B)


      1 use std::collections::HashMap;
      2 
      3 pub struct Calculator {
      4     pub variables: HashMap<String, f64>,
      5     pub history: Vec<Calculation>,
      6     pub last_result: Option<f64>,
      7 }
      8 
      9 pub struct Calculation;
     10 
     11 impl Calculator {
     12     pub fn store_calculation(&self, expression: String, result: f64) {
     13         todo!()
     14     }
     15 
     16     pub fn get_variable(&self, name: &str) -> Option<f64> {
     17         todo!()
     18     }
     19 
     20     pub fn set_variable(&self, name: &str, value: f64) -> Result<(), String> {
     21         todo!()
     22     }
     23 }