I am trying to run this code, but I am making some mistakes and can't find which one
Class Node {
[int] $data
[Node] $next
Node() {
$this.data = 0
$this.next = $null
}
Node ( [Int]$value,[Node]$nextnode) {
$this.data = $value
$this.next = $nextnode
}
}
Class LinkedList {
[Node] $top
[int] $count
LinkedList() {
$this.top = [Node]::new()
$this.count = 0
}
Linkedlist ( [int[]] $value){
foreach ($elt in $value){
$this.Push($elt)
}
}
[int] Size() {
return $this.count
}
[Node] Head() {
if ($this.top -ne $null){
return $this.top
}else{
Throw "*The List is empty*"
}
}
[void] Push([int] $var) {
if ( -not $this.top ){
$this.top = [Node]::new($var,$null)
}else{
$this.top = [Node]::new($var,$this.top)
}
$this.count++
}
[Int]Pop() {
if ($this.top){
$suppnode=$this.top.data
$this.top=$this.top.next
$this.count--
return $suppnode
}else{
Throw "The list is empty"
}
}
[void] Reverse() {
$count=$this.count
for ($i=0, $i -le $count, $i++ ){
$list += $this.pop
}
for ($i=0, $i -le $count, $i++ ){
$this.Push($list[i])
}
}
[array] ToArray() {
foreach ($elt in $this.Reverse()){
$array+=$elt.data
}
return $array
}
}```