Skip to content
Permalink
Browse files

by ref proficiency exercise model solution looks good.

  • Loading branch information...
CorySanin committed Jan 18, 2019
1 parent 6ec1f9d commit 4af4e6e9fca83f01a31f657613cd40623cd1b52b
Showing with 64 additions and 5 deletions.
  1. +62 −5 AV/PL/paramPassingByRefPRO.js
  2. +2 −0 AV/PL/paramPassingByValPRO.js
@@ -93,27 +93,80 @@ $(document).ready(function () {

// Process About button: Pop up a message with an Alert
function about() {
alert(ODSA.AV.aboutstring(interpret(".avTitle"), interpret("av_Authors")));
alert(ODSA.AV.aboutstring('By Reference proficiency exercise', 'Cory Sanin'));
}

// generates the model answer
function modelSolution(modeljsavAV) {
var currentTopMargin = 0;
var topMargin = 0;
var fooVars = {};
var classVars = {};
var mainVars = {};
var labelobj;
var currentLine = fooIndex;
function unhighlightAll(){
unhighlightElements(classVars);
unhighlightElements(mainVars);
}

var pseudo = modeljsavAV.code(codeLines,
{left: leftMargin, top: topMargin, lineNumbers: false}
);
jsavElements.push(pseudo);

//run foo()
for(arr in initialArrays.classVars){
classVars[arr] = modeljsavAV.ds.array(initialArrays.classVars[arr]);
jsavElements.push(classVars[arr]);
labelobj = modeljsavAV.label(arr,
{
relativeTo:pseudo, anchor:"right top", myAnchor:"left top",
left: leftMargin, top: currentTopMargin
}
);
classVars[arr] = modeljsavAV.ds.array(initialArrays.classVars[arr],
{
indexed: initialArrays.classVars[arr].length > 1,relativeTo:labelobj, anchor:"right top",
myAnchor:"left top", left: labelMargin,
top:-1*jsavArrayOffset
}
);
jsavElements.push(classVars[arr], labelobj);
currentTopMargin += lineHeight;
}

currentTopMargin += lineHeight;

jsavElements.push(modeljsavAV.label("main",
{
relativeTo:pseudo, anchor:"right top", myAnchor:"left top",
left: leftMargin, top: currentTopMargin
}
));

currentTopMargin += lineHeight;
var numVars = Object.keys(initialArrays.mainVars).length;

jsavElements.push(modeljsavAV.g.rect(2*leftMargin+pseudo.element[0].clientWidth,
currentTopMargin+topMargin,
boxWidth,
lineHeight*numVars+boxPadding*numVars
));

for(arr in initialArrays.mainVars){
mainVars[arr] = modeljsavAV.ds.array(initialArrays.mainVars[arr]);
jsavElements.push(mainVars[arr]);
labelobj = modeljsavAV.label(arr,
{
relativeTo:pseudo, anchor:"right top", myAnchor:"left top",
left: leftMargin, top: currentTopMargin
}
);
mainVars[arr] = modeljsavAV.ds.array(initialArrays.mainVars[arr],
{
indexed: initialArrays.mainVars[arr].length > 1,relativeTo:labelobj, anchor:"right top",
myAnchor:"left top", left: labelMargin,
top:-1*jsavArrayOffset
}
);
jsavElements.push(mainVars[arr], labelobj);
}
for(var arr in initialArrays.fooVars){
if(arr.length > 1){
@@ -122,6 +175,10 @@ $(document).ready(function () {
else{
var split = initialArrays.fooVars[arr].split(':');
fooVars[arr] = ((split[0]==='mainVars')?mainVars:classVars)[split[1]];
jsavElements.push(modeljsavAV.pointer(arr, ((split[0]==='mainVars')?mainVars:classVars)[split[1]],{
targetIndex: initialArrays.fooVars[arr+'-index'],
left: lineHeight
}));
}
}

@@ -135,6 +135,8 @@ $(document).ready(function () {
currentTopMargin += lineHeight;
}

currentTopMargin += lineHeight;

jsavElements.push(modeljsavAV.label("main",
{
relativeTo:pseudo, anchor:"right top", myAnchor:"left top",

0 comments on commit 4af4e6e

Please sign in to comment.
You can’t perform that action at this time.