Advertisement
Carcigenicate

Problem

Dec 3rd, 2014
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.37 KB | None | 0 0
  1. package tutorial
  2.  
  3. class Node(newCargo: Int) {
  4.     var cargo = newCargo
  5.     var next: Node = null
  6.    
  7.     def add(newCargo: Int) {
  8.         next = new Node(newCargo)
  9.     }
  10.    
  11.     def getNext(): Node = {
  12.         return next
  13.     }
  14. }
  15.  
  16. class LinkedList() {
  17.     var head = null
  18.     var tail = null
  19.     var length = 0
  20.    
  21.     def pushBack(newCargo: Int) {
  22.         tail.add(new) // Line 22
  23.         tail = tail.next
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement