forked from csarkar373/python-games
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringnegpcn.js
More file actions
32 lines (29 loc) · 1.02 KB
/
stringnegpcn.js
File metadata and controls
32 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import QuestionBaseClass from "../components/questionbaseclass";
//import * as StringConstants from "./stringconstants";
function stringQuestionNegPCN(props) {
const currentWord = "ABCDEFGH";
// question will have 1 row and 8 columns
const sq = new QuestionBaseClass(props, 1, currentWord.length);
// adjust the button display values
for (let i = 0; i < currentWord.length; ++i) {
sq.displayValues[0][i] = currentWord.substring(i, i + 1);
}
//console.log("array question base class", sq);
sq.pointValue = 3;
sq.rows = 1;
const lowerBound = Math.floor((Math.random() * currentWord.length) / 2);
let upperBound =
Math.floor(Math.random() * (currentWord.length - lowerBound - 1)) +
lowerBound +
1;
for (let i = lowerBound; i < upperBound; i += 1) {
sq.buttonStates[0][i] = 1;
}
upperBound = upperBound - currentWord.length;
sq.text = [
'string = "' + currentWord + '"',
"print( string[" + lowerBound + ":" + upperBound + " ])",
];
return sq;
}
export default stringQuestionNegPCN;