Skip to content
Open
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
74 changes: 51 additions & 23 deletions calculator.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,57 @@
<?php
class Calculator{

public function add($numbers_to_add){
$sum = 0;
foreach($numbers_to_add as $num){
$sum = $num + $sum;
}
return $sum;
}

public function subtract($x, $y){
return $x - $y;
}
/**
* Class Calculator
**/
class Calculator
{
/**
*
* @param [type] $numbers_to_add
* @return void
*/
public function add($numbers_to_add)
{
$sum = 0;
foreach ($numbers_to_add as $num) {
$sum = $num + $sum;
}
return $sum;
}

public function multiply($numbers_to_multiply){
$product = 1;
foreach($numbers_to_multiply as $num){
$product = $num * $product;
}
return $product;
}
/**
*
* @param [type] $x
* @param [type] $y
* @return void
*/
public function subtract($x, $y)
{
return $x - $y;
}

public function divide($x, $y){
return $x / $y;
}
/**
*
* @param [type] $numbers_to_multiply
* @return void
*/
public function multiply($numbers_to_multiply)
{
$product = 1;
foreach ($numbers_to_multiply as $num) {
$product = $num * $product;
}
return $product;
}

/**
*
* @param [type] $x
* @param [type] $y
* @return void
*/
public function divide($x, $y)
{
return $x / $y;
}
}
?>