Skip to content

Commit

Permalink
finish q3
Browse files Browse the repository at this point in the history
  • Loading branch information
tkjnz committed Jan 7, 2016
1 parent 5da4f92 commit 7ba1816
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions question_2.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ class Bronze_Customer extends Customer {
public function deposit($amount){
$this->balance = $this->get_balance() + $amount;
}


/**
* Instantiate the correct object for customer ID
* @return bool
*/
public function get_instance(){
$id= $this->id;
if (strlen($id) <=10 && substr($id,0,1) == 'B') {
return true;
}
else {
throw new \InvalidArgumentException('Invalid customer ID');
}
}
}

/**
Expand All @@ -49,6 +64,20 @@ class Silver_Customer extends Customer {
public function deposit($amount){
$this->balance = $this->get_balance() + $amount * (1.05);
}

/**
* Instantiate the correct object for customer ID
* @return bool
*/
public function get_instance(){
$id= $this->id;
if (strlen($id) <=10 && substr($id,0,1) == 'S') {
return true;
}
else {
throw new \InvalidArgumentException('Invalid customer ID');
}
}
}

/**
Expand All @@ -64,4 +93,18 @@ class Gold_Customer extends Customer {
public function deposit($amount){
$this->balance = $this->get_balance() + $amount * (1.1);
}

/**
* Instantiate the correct object for customer ID
* @return bool
*/
public function get_instance(){
$id= $this->id;
if (strlen($id) <=10 && substr($id,0,1) == 'G') {
return true;
}
else {
throw new \InvalidArgumentException('Invalid customer ID');
}
}
}

0 comments on commit 7ba1816

Please sign in to comment.