// a class should have a single primary responsibility

const fs = require('fs');

class Journal {
    constructor() {
        this.entries = {};
        this.count = 0;
    }

    addEntry(text) {
        let c = ++this.count;
        let entry = `${c}: ${text}`;
        this.entries[c] = entry;
        return c;
    }

    removeEntry() {
        delete this.entries[index];
    }

    toString() {
        return Object.values(this.entries).join('\n');
    }
}
 class PersistenceManager {
     saveToFile(journal, filename) {
         fs.writeFileSync(filename, journal.toString());
     }

     load(filename) {
         //
     }

     loadFromUrl(url) {
         //
     }
 }

let j = new Journal();

j.addEntry('I cried today.');
j.addEntry('I ate a bug.');
console.log(j.toString());

let p = new  PersistenceManager();
let filename = '/home/gvs/dev/open_source/react_native_dev_roadmap/journal.txt'
p.saveToFile(j, filename);

// separation of concerns

