CodeHSConsole

CodeHSConsole

new CodeHSConsole()

Set up an instance of the console library.
Source:

Methods

(static) clear()

Clear the console's text.
Source:

(static) exists()

Check if the console exists. Important to check before attempting to select and extract output.
Source:

(static) getNamespaceModifcationString() → {string}

Generate strings for the public methods to bring them to the public namespace without having to call them with the console instance.
Source:
Returns:
Type:
string
Line broken function definitions.

(static) getOutput() → {string}

Get the output from the console.
Source:
Returns:
Type:
string

(static) getStubString() → {string}

Generate stub strings for the public methods to bring them to the namespace without having to call them with the console instance.
Source:
Returns:
Type:
string
Line broken function definitions.

(static) registerPublicMethod(name)

Adds a method to the public methods array.
Source:
Parameters:
Name Type Description
name string Name of the method.

(static) setSolution(soln)

Set the solution code for a given exercise.
Source:
Parameters:
Name Type Description
soln string Solution code.

checkOutput()

Check the console output for correctness against solution code. returns {object} Dictionary containing boolean of success and message.
Source:

clear()

Clear the console.
Source:

flushQuietOutput()

Gets the internal output.
Source:

hasUserinput(code)

Method to test whether the code is requesting user input at all.
Source:
Parameters:
Name Type Description
code string The code from the editor

print(ln)

Print a line to the console.
Source:
Parameters:
Name Type Description
ln string The string to print.

println(ln)

Print a line to the console.
Source:
Parameters:
Name Type Description
ln string The string to print.

quietPrint()

A non-dom-mutating print for use in autograders.
Source:

quietPrintln()

A non-dom-mutating println for use in autograders.
Source:

readBoolean(str) → {str}

Read a bool from the user.
Source:
Parameters:
Name Type Description
str str A message associated with the modal asking for input.
Returns:
Type:
str
The result of the readBoolean prompt.

readLine(str) → {str}

Read a line from the user.
Source:
Parameters:
Name Type Description
str str A message associated with the modal asking for input.
Returns:
Type:
str
The result of the readLine prompt.

readLinePrivate(str, looping)

Private method used to read a line.
Source:
Parameters:
Name Type Description
str string The line to be read.
looping boolean Unsure. This is a messy method.

runCode(code)

This is how you run the code, but get access to the state of the console library. The current instance becomes accessible in the code.
Source:
Parameters:
Name Type Description
code string The code from the editor.