Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions chargen.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@

$person = new Character();
$this_person = new View($person);
print("Your new crew: {$this_person}\n");
?>
print $this_person;
10 changes: 4 additions & 6 deletions lib/character.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ public function __construct($data = array()) {
$this->upp_s = $this->upp_to_s($this->upp);
}

public function to_s() {
$upp_s = $this->upp_to_s($this->upp);
print("$this->name [$this->gender] $upp_s \n");
public function __toString() {
$return_string = "{$this->name} [{$this->gender}] {$this->upp_s}";
return $return_string;
}

private function set_gender() {
return rand(0,1) ? "F" : "M";
}
private function upp_to_s(array $upp) {
$string = '';
$string = '';
foreach ($upp as $s) {
$string .= dechex($s);
}
Expand Down Expand Up @@ -74,5 +74,3 @@ private function go_to_the_gym(array $upp) {
}

}
?>

13 changes: 6 additions & 7 deletions lib/view.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?php

class View {
public function __construct($person) {
$this->name = $person->name;
$this->gender = $person->gender;
$this->upp_s = $person->upp_s;
protected $person;

public function __construct(Character $person) {
$this->person = $person;
}

public function __toString() {
$return_string = "$this->name [$this->gender] $this->upp_s";
$return_string = "Your new crew: {$this->person}\n";
return $return_string;
}
}
?>