using UnityEngine; using System.Collections; using System; public class DefaultNode : Node { private T attribute; private Node next; //private TailNode tailNode; private T attribute2; private Node next1; public DefaultNode(T attribute, Node next) { this.attribute = attribute; this.next = next; } // public DefaultNode(Node attribute1, TailNode tailNode) // { // this.attribute1 = attribute1; // this.tailNode = tailNode; // } public Node getNext() { return next; } public T getAttribute() { return attribute; } public Node addLast(T attribute) { Node node = next.addLast(attribute); return new DefaultNode(this.attribute, node); } public Node add(int currentNum, int num, T attribute) { Node newNode; if (currentNum == num) { newNode = new DefaultNode(attribute, this.next); return new DefaultNode(this.attribute, newNode); } newNode = next.add(currentNum + 1, num, attribute); if (newNode == null) return null; return new DefaultNode(this.attribute, newNode); } public Node delete(int currentNum, int deleteNum) { if (currentNum == deleteNum) { return new DefaultNode (this.attribute, this.next.getNext ()); } Node newNode = next.delete (currentNum + 1, deleteNum); if (newNode == null) { return null; } return new DefaultNode(this.attribute, newNode); } public Node replaceNode(int currentNum, int num, T attribute) { if (currentNum == num) { return new DefaultNode(attribute, this.getNext()); } Node newNode = next.replaceNode(currentNum + 1, num, attribute); if (newNode == null) { return null; } return new DefaultNode(this.attribute, newNode); } public int length() { return next.length() + 1; } public T getAttribure() { throw new NotImplementedException(); } }