OOP and Class impementation Tech help

Trying to use applab to transition from APCSP to APCSA, so I’m trying to implement a class in applab. I’m using known javascript code to create the class and constructor, and initially applab doesn’t flag any errors. When I try to run the code, however, I’m getting a “Unexpected token” error for the line Class Draph{ which is the line declaring the class. Applab recognizes the Class, constructor, and this keywords as they are immediately color coded. Has anyone ever coded a class successfully in applab? Am I mssing something specific to this compiler?
Entire code below:
class Dgraph{
constructor Dgraph(vTotal){
this.vTotal = vTotal;
this.adjList = new Map();
}
addVertex(v) {
this.adjList.set(v, );
}
addEdge(v,map){
this.adjList.get(v).push(map);
}
printGraph(){
var getKeys = this.adjList.keys();
for (var i of getKeys){
var getValues = this.adjList.get(i);
var adder = “”;
for (var j of getValues){
adder += j + " ";
}
console.log(i + " -> " + adder);
}
}
}
var vertexTotal = prompt(“How many vertices?”);
var vertices = ;
for (var k=0; k<vertexTotal; k++){
var tempV = prompt(“What is the name of vertex “+ (k+1)+”?”);
appendItem(vertices,tempV);
}
var graph = new Dgraph(vertexTotal);
for (var l=0;l<vertexTotal;l++){
graph.addVertex(vertices[l]);
}
var tempE1;
var tempE2;
var flag = true;
while (flag){
var cont = prompt(“Do you want to add an edge? Y/N”);
if (cont == “N”)
flag = false;
else if (cont == “Y”){
tempE1 = prompt(“What is the starting vertex?”);
tempE2 = prompt(“What is the ending vertex?”);
graph.addEdge(tempE1,tempE2);
}
}
graph.printGraph();

Hi @kjstacey,

Welcome to the code.org forums. :slight_smile:

I won’t be much help since I haven’t tried doing stuff with classes in App Lab, but I’ll try to get someone else with more knowledge about that to take a look at this. Do keep in mind some features may not be supported, since our priorities are to support the use of App Lab in context of the CS Principles course, and OOP is outside of that as far as I know. (But we’ll do our best to help)

Meanwhile, it really helps us troubleshoot if you can use the “Share” feature in App Lab and post the link here so someone can directly dig around in the code and run it.

Frank

Thank you for your reply, like I said I’m hoping to transition from csp to CSA which uses java, so if I could show them classes in app lab it would make an easier transition. (Which is something to think about if you ever want to expand your curriculum options
upwards :grinning:). I did publish the code. It’s under graph class example oop.