-
-
Save kentfredric/4128777 to your computer and use it in GitHub Desktop.
IT"S EVEN MORE BEAUTIFUL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Question { | |
public $questionName; | |
public $choiceValue; | |
public function __construct($questionName, $choiceValue){ | |
$transtbl = array( | |
1 => "hate", | |
2 => "Don't prefer", | |
3 => "are ok with", | |
4 => "awesome is the word for", | |
); | |
$this->choiceValue = $choiceValue; | |
if ( array_key_exists( $questionName, $transtbl ) ) { | |
$name = $transtbl[$questionName]; | |
} else { | |
$name = "love"; | |
} | |
$this->questionName = $name; | |
} | |
public static function cmp_obj($a, $b) | |
{ | |
$al = $a->choiceValue; | |
$bl = $b->choiceValue; | |
if ($al == bl) { | |
return 0; | |
} | |
return ($al > bl) ? +1 : -1; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment