Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include ( "/var/www/challenges/challenges/java/java.class.php" );
- function getChallenge()
- {
- return new JavaIntroIChallenge();
- }
- class JavaIntroIChallenge extends JavaChallenge
- {
- public function __construct()
- {
- parent::__construct( 1, "public static void printHelloWorld() {\n\n}\n" );
- }
- public function getFullCode( $cName, $subCode )
- {
- return "public class $cName {\npublic static void main(String[] args) {printHelloWorld();} $subCode }";
- }
- public function getResults( $output )
- {
- $results = array( "success" => false );
- if ( empty( $output ) )
- {
- $results['success'] = false;
- } else
- {
- foreach ( $output['output'] as $line )
- {
- if ( preg_match( "/.*hello.*world.*/i", strtolower( $line ) ) )
- {
- $results['success'] = true;
- $results['tr'][0]['expected'] = "hello world";
- $results['tr'][0]['thisrun'] = $line;
- $results['tr'][0]['ok'] = "✓";
- $results['tr'][0]['color'] = "green";
- break;
- } else
- {
- $results['success'] = false;
- $results['tr'][0]['expected'] = "hello world";
- $results['tr'][0]['thisrun'] = $line;
- $results['tr'][0]['ok'] = "X";
- $results['tr'][0]['color'] = "red";
- }
- }
- }
- return $results;
- }
- public function printSolution()
- {
- return "<p><div align=left><code>public static void printHelloWorld() {<br><p>System.out.println(\"Hello world!\");</p><br>}<br></code></div></p>";
- }
- public function getDescription()
- {
- return $this->desc;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement