In [ ]:
class Circle {
constructor (radius) {
this.radius = radius;
}
get area () {
return Math.PI * this.radius * this.radius;
}
set area (n) {
this.radius = Math.sqrt(n / Math.PI);
}
}
In [1]:
class SLLNode {
constructor(data) {
this.data = data
this.next = null
}
get end () {
}
}
Out[1]:
In [ ]:
var traverse = sllNode => {
}
In [2]:
var myNode = new SLLNode(3)
In [ ]:
myNode.next = new SLLNode(5)
In [ ]:
myNode.next
In [ ]:
In [ ]:
var SLLNode = val => {
let value = val
const getValue = () => value
const setValue = newValue => value = newValue
let next = null
const getNext = () => next
const setNext = Node => next = Node
const traverse = () => {
if (value) console.log(value)
if (next) next.traverse()
}
return {getValue, setValue, getNext, setNext, traverse}
}
In [ ]:
var myNode = SLLNode(1)
In [ ]:
myNode.getValue()
In [ ]:
myNode.setValue(5)
In [ ]:
myNode.getValue()
In [ ]:
In [ ]:
myNode.setNext(SLLNode(2))
In [ ]:
myNode.traverse()
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
myC = new Circle(3)
In [ ]:
myC.area = 3
In [ ]:
myC.radius
In [ ]: