These are chat archives for CTownsdin/SatChat

8th
Nov 2014
Joe Elsey
@joeelsey
Nov 08 2014 19:45 UTC
Howdy
CTownsdin
@CTownsdin
Nov 08 2014 19:45 UTC
hi
Stephanie Lingwood
@stephanielingwood
Nov 08 2014 19:46 UTC
Hi there
Hey Hiroshi - you coding this morning?
Hiroshi Nagata
@HIROSN
Nov 08 2014 19:46 UTC
hi
Stephanie Lingwood
@stephanielingwood
Nov 08 2014 19:53 UTC
You can join our code party virtually (we're all in the co-working space). So far, we're working on a mix of assignments. Christian and I have the data structures done. Christian, Joe and I have the simple json database done (I did testing, though it has some errors). Joe has the mongo persistence layer done, and is going to work on the Modular JS assignment this morning. Christian and I are tackling the mongo persistence layer assignment.
What are you working on, Hiroshi?
Hiroshi Nagata
@HIROSN
Nov 08 2014 19:54 UTC
I'm working on mongo persistence layer
CTownsdin
@CTownsdin
Nov 08 2014 20:00 UTC
here's some stuff for linked lists... incoming...
Stephanie Lingwood
@stephanielingwood
Nov 08 2014 20:00 UTC
Cool. That's what Christian and I are workign on. Joe is going to work on linked lists.
CTownsdin
@CTownsdin
Nov 08 2014 20:01 UTC
// Pair Progammed with Stephanie and Karl ! :)  Go Team

// The Node Class
function Node (element) {
    this.element = element;
    this.next = null;  // Note!
}
// The LList Class
function LList () {
    this.head = new Node("head");
}
LList.prototype.find = function (item) {
    var currNode = this.head;
    while (currNode.element !== item) {  // while (not found)
        currNode = currNode.next;   // keep looking
    }
    return currNode;    // return found item
};
LList.prototype.insert = function (newElement, item) {
    var newNode = new Node(newElement);
    var current = this.find(item);
    newNode.next = current.next;
    current.next = newNode;
};
LList.prototype.display = function () {
var currNode = this.head;
while (currNode.next !== null) {
          console.log(currNode.next.element);
          currNode = currNode.next;
       }
};
LList.prototype.findPrevious = function (item) {
var currNode = this.head;
    while ((currNode.next !== null) &&
                   (currNode.next.element !== item)) {
        currNode = currNode.next;       // keep looking till we find prev
    }
    return currNode;    // return prev
};
LList.prototype.remove = function (item) {
    var prevNode = this.findPrevious(item);
    if (prevNode.next !== null) {  // we don't remove items that don't exist!
           prevNode.next = prevNode.next.next;  // move pointer
    }
};
LList.prototype.advance = function(item, n) {
    var current = this.find(item);
    var temp = current;
    this.remove(item);
    for (var i = 0; i < n; i++) {
      current = current.next;
    }
    temp.next = current.next;
   current.next = temp;
};
LList.prototype.hi = function (name) {
    console.log('hi ' + name);
}

module.exports = LList;

// var cities = new LList();
// cities.insert("Con", "head");
// cities.insert("Rus", "Con");
// cities.insert("Alm", "Rus");
// cities.insert("Dom", "Alm");
// cities.insert("Eve", "Dom");
// cities.display();
// console.log('-------\n');

// cities.advance("Alm", 2);
// cities.display();
// // console.log('-------\n');
and now, student grades, #4 Linked List code
```
// Pair Progammed with Stephanie and Karl ! :)  Go Team
module.exports = function () {
// The Node Class
//             "name"
function Node(element, grade) {
    this.element = element;
    this.grade = grade || 0;
    this.next = null;  // Note!
}
// The LList Class
function LList() {
    this.head = new Node("head");
    this.tail = this.head;
    // this.remove = remove;    :TODO
}
LList.prototype.find = function (item) {
    var currNode = this.head;
    while (currNode.element !== item) {  // while (not found)
        currNode = currNode.next;   // keep looking
    }
    return currNode;    // return found item
};
LList.prototype.findPrevious = function (item) {
var currNode = this.head;
    while ((currNode.next !== null) &&
                   (currNode.next.element !== item)) {
        currNode = currNode.next;       // keep looking till we find prev
    }
    return currNode;    // return prev
};
LList.prototype.remove = function (item) {
    var prevNode = this.findPrevious(item);
    if (prevNode.next !== null) {
           prevNode.next = prevNode.next.next;  // move pointer
    }
    else {
      this.tail = prevNode;
    }
};
LList.prototype.advance = function(item, n) {
    var current = this.find(item);
    var temp = current;
    this.remove(item);
    for (var i = 0; i < n; i++) {
      current = current.next;
    }
    temp.next = current.next;
    current.next = temp;
};
// ADD STUDENT FUNCTION
LList.prototype.addStudent = function (newElement, grade) {
    var newNode = new Node(newElement, grade);
    var current = this.tail;
    newNode.next = current.next;
    current.next = newNode;
    this.tail = newNode;
};
// UPDATE GRADE FUNCTION
LList.prototype.updateGrade = function (student, grade) {
    var currNode = this.head;
    while (currNode.element !== student) {  // while (not found)
        currNode = currNode.next;   // keep looking
    }
    currNode.grade = grade;
    console.log(student + '--' + currNode.grade); // report to teacher
};
// SHOW GRADE FUNCTION
LList.prototype.displayStudent = function(student) {
  //find the node
  var current = this.find(student);
  //show stuff. console log it
  console.log(student + '--' + current.grade);
};
// SHOW ALL GRADES FUNCTION
LList.prototype.displayAll = function () {
var currNode = this.head;
while (currNode.next !== null) {
          console.log(currNode.next.element + ' ' + currNode.next.grade);
          currNode = currNode.next;
       }
};

// Write a program that uses a singly linked list to keep track of a set of test // grades entered interactively into the program.

};

// var classList = new LList();
// classList.addStudent("Alice", 95);
// classList.addStudent("Rus", 85);
// classList.addStudent("Ada");
// classList.displayAll();

// classList.displayStudent('Rus');
// classList.updateGrade('Ada', 95);
^ Tyler's Repo for
Create a JSON api with a Mongo Persistence Layer and get it running on Heroku
Joe Elsey
@joeelsey
Nov 08 2014 22:29 UTC
shout if you need anything christian.
CTownsdin
@CTownsdin
Nov 08 2014 22:41 UTC
what's the downstairs door code please?
just seeking a quiet place to bangout some work