We have updated the content of our program. To access the current Software Engineering curriculum visit curriculum.turing.edu.
A Perilous Journey
Iteration 1 - Append, To String, and Count (Single Node)
Great! We have nodes. In this iteration we’ll create the LinkedList
class and start filling in the basic functionality needed to append our first node.
We’ll be adding the following methods:
.append
- adds a new piece of data (data can really be anything) to the list.count
- tells us how many things are in the list.to_string
- generates a string of all the families in the list
But for now, focus on building these functions so they work for just the first element of data appended to the list (we’ll handle multiple elements in the next iteration).
Expected behavior:
> require "./lib/linked_list"
> list = LinkedList.new
=> <LinkedList @head=nil #45678904567>
> list.head
=> nil
> list.append("West")
=> <Node @surname="West" @next_node=nil #5678904567890>
> list
=> <LinkedList @head=<Node @surname="West" ... > #45678904567>
> list.head.next_node
=> nil
> list.count
=> 1
> list.to_string
=> "The West family"