Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Tariff
- {
- protected $total = 0;
- protected $yearlyStaticExpenses = 0;
- protected $name = '';
- protected $consumptionCosts = 0;
- abstract protected function setYearlyStaticExpenses($yearlyStaticExpenses = null);
- abstract protected function calculate();
- protected function getYearlyStaticExpenses()
- {
- return $this->yearlyStaticExpenses;
- }
- protected function setPrice($price)
- {
- $this->price = $price;
- return $this;
- }
- protected function getPrice()
- {
- return $this->price;
- }
- protected function setName($name)
- {
- $this->name = $name;
- return $this;
- }
- protected function getName()
- {
- return $this->name;
- }
- protected function setConsumptionCosts($consumptionCosts)
- {
- $this->consumptionCosts = $consumptionCosts;
- return $this;
- }
- protected function getConsumptionCosts()
- {
- return $this->consumptionCosts;
- }
- protected function centsToEur(int $cents)
- {
- return sprintf("%2f", round($cents / 100), 2);
- }
- }
- class BasicElectricityTariff extends Tariff
- {
- private $baseCostPerMonth = 500;
- protected $name = "Basic Electricity Tariff";
- protected $consumptionCosts = 22;
- public function __construct(array $input)
- {
- $this->input = $input;
- $this->setYearlyStaticExpenses($this->baseCostPerMonth);
- }
- protected function setYearlyStaticExpenses($baseCostPerMonth)
- {
- $yearlyStaticExpenses = $baseCostPerMonth * 12;
- $this->yearlyStaticExpenses = $yearlyStaticExpenses;
- return $this;
- }
- protected function calculate()
- {
- $spending = $this->input['kWhy'] * $this->getConsumptionCosts();
- $total = $this->getYearlyStaticExpenses() + $spending;
- return $total;
- }
- }
- class PackagedTariff extends Tariff
- {
- private $paidLimit = 4000;
- protected $yearlyStaticExpanses = 80000;
- protected $name = "Packaged Tariff";
- protected $consumptionCosts = 30;
- public function __construct(array $input)
- {
- $this->setYearlyStaticExpenses($this->yearlyStaticExpanses);
- }
- protected setYearlyStaticExpenses($yearlyStaticExpanses)
- {
- $this->yearlyStaticExpanses = $yearlyStaticExpanses;
- return $this;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement