Jump to content

resolate

New Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral

About resolate

  • Rank
    Newbie
  1. resolate

    unknown output, how can i avoid it?

    OMG i see it now... Thanks Jackques1. Still it strikes me as a surprise that this code is printed above the table headings, since the ">" duplication is found beneath... Any ideas on my design pattern? I especially have trouble creating my Validator class. There are many to be found as open source libraries, but the configuration makes my head explode with the knowledge i only have at this point... And thanks for the link of the validater, i ll definately be using it
  2. Hello, I have some trouble in my code. For now i am trying to output an amortization table that i calculated inside a class. I achieve for the table to be outputted, but there is also an instance of ">>>>>" being outputted and i do not know from where... I have added an image below so you can see the output of the ">>>>". Here's my code: <?php include './index.php'; $val = new Validator(); $input = new Input($val->getSanitized()['input-aw'], $val->getSanitized()['input-i'], $val->getSanitized()['input-n']); $loanHL = new LoanHL($input); $loanHL->calculate(); ?> <table class="table"> <thead> <tr> <th>periode</th> <th>schuld</th> <th>aflossing</th> <th>waarvan intrest</th> <th>waarvan kapitaal</th> <th>restschuld</th> </tr> </thead> <tbody> <?php foreach ($loanHL->getCalculateData() as $key => $val) { echo '<tr>'; echo '<td>' . $loanHL->getCalculateData()[$key]['period'] . '</td>>'; echo '<td>' . $loanHL->getCalculateData()[$key]['aw'] . '</td>>'; echo '<td>' . $loanHL->getCalculateData()[$key]['payment'] . '</td>>'; echo '<td>' . $loanHL->getCalculateData()[$key]['intrestPayment'] . '</td>>'; echo '<td>' . $loanHL->getCalculateData()[$key]['capitalPayment'] . '</td>>'; echo '<td>' . $loanHL->getCalculateData()[$key]['debt'] . '</td>>'; echo '</tr>'; } ?> </tbody> </table> The calculatedata comes from the following two things: public function getCalculateData() { return $this->calculateData; } public function calculate() { $annuity = $this->calcAnnuity($this->workData['aw'],$this->workData['i'],$this->workData['n']); for ($ii = 0; $ii < $this->workData['n']; $ii++) { $this->calculateData[$ii +1]['period'] = $ii + 1; $this->calculateData[$ii +1]['aw'] = $this->calcAw($annuity,$this->workData['i'],$ii,$this->workData['n']); $this->calculateData[$ii +1]['payment'] = $annuity; $this->calculateData[$ii +1]['intrestPayment'] = $this->calcAw($annuity,$this->workData['i'],$ii,$this->workData['n']) * $this->workData['i']; $this->calculateData[$ii +1]['capitalPayment'] = $annuity - ($this->calcAw($annuity,$this->workData['i'],$ii,$this->workData['n']) * $this->workData['i']); $this->calculateData[$ii +1]['debt'] = $this->calcAw($annuity,$this->workData['i'],$ii + 1,$this->workData['n']); } } Appreciate all the help! Also some pointers on my design pattern are welcome, i am new to PHP OOP trying to get the hang of it grtz, Resolate
  3. Hello, I am a newbie and catching up on php OOP. I have a handy project that i would like to mold into a OOP-driven web application. For the sake of simplicity i will describe a minor part of the application's goals. I should be able to scale later, but the most important thing is getting the design pattern ready. Goal of the application: I wish to provide people with different loan types (eg mortgage loan; declining,...) as to allow them to pick their best suitable type. For this i use a fom that catches the basic loan information and goes to work. For simplicity let's say that i only require the following fields: Ammount loaned (€) rate (%) periode (years) (i will add more later like taxrate; early repayments, number of kids,... everything that changes the outcome of tax benefits etc) And let's say that to start off, we only have 2 types of loans: mortgage loan declining loan (more options added later that make use of early repayments) The things i need the app to output are: A different tab for each type of loan under which can be found: Amortization table tax benefit summary in KPIs (ROI (-), total ammount payed, total interest paid,... And one final summary screen comparing all the elements of the different loan types. So far everything clear in my mind.... As for the design pattern this would be my idea: create a (service) validator class that validates form input and instantializes upon succes a new (model) class that contains the validated input Input (model) class as described above Loan class being abstract containing financial methods to calculate the payments in the different periods Loan classes based upon the abstract class but differing by type and thus overriding some of the methods for the specific type. Maybe a different class to contain the results of the calculation (model)? I made all these calculations in excel when i had to make the decision of buying a house. The reason why i want to turn this into a webapp is because of people asking me about those calculations, so why not make it available for everyone (atleast those in my country as tax regulation will surely differ). I have added screenshots from my excel file to give you a better idea of what i am trying to accomplish. I made it work in excel VBA with very bad procedural code. I Could do the same in PHP, but then i d not be improving myself... So let's get OOP going! What do you think about this idea? And for the purpose of it being programmed as OO? Should i take a different approach with my classes? Any help is well appreciated! Grtz, Resolate
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.