languages

A collection of programs made with different programming languages.
git clone git://evanalba.com/languages
Log | Files | Refs

todo_item.cpp (700B)


      1 /*
      2  * Name        : todo_item.cpp
      3  * Author      : Evan Alba
      4  * Description : CPP File for class TodoItem.
      5  */
      6 
      7 #include "todo_item.h"
      8 
      9 void TodoItem::set_description(std::string info) {
     10   description_ = info;
     11 }
     12 
     13 void TodoItem::set_priority(int rank) {
     14   if ((rank >= 1) && (rank <= 5)) {
     15     priority_ = rank;
     16   } else {
     17     priority_ = 5;
     18   }
     19 }
     20 
     21 void TodoItem::set_completed(bool state) {
     22   completed_ = state;
     23 }
     24 
     25 std::string TodoItem::ToFile() {
     26   return scrub(description_) + "@" + std::to_string(priority_) + "@"
     27   + std::to_string(completed_);
     28 }
     29 
     30 /* PRIVATE FUNCTION BELLOW */
     31 std::string TodoItem::scrub(std::string edit) {
     32   std::replace(edit.begin(), edit.end(), '@', '`');
     33   return edit;
     34 }