Interface and abstract class

I have a simple question about interfaces and abstract classes. My professor wanted to use my calculator php program in class as an example, but he told me to add an interface first. Everything I have read online seems like you run one or the other abstract or interface.

Would I be able to add an interface before my abstract class and extended class? My code looks basically like this:

Interface?

Abstract class calc
{
Code
}
New class calculations extends cal
{
Code
}

yes it does work ! i posted the question while at work because it was driving me crazy, but i tested it and got it working in 2 mins lol. i am not sure if I need my other functions in the interface, or if just the add is good enough. It runs like this tho, so i guess thats good for something.

heres my code:

[php]$page = $_GET[‘page’];

interface Itest
{

function add($number1, $number2);
}

abstract class calculator implements Itest {
private $number1;
private $number2;

     function add($number1,$number2) 
      { 
               $result =$number1 + $number2; 
                echo("The sum of $number1 and $number2 is $result<br><br>"); 
                echo("$number1 + $number2 = $result"); 
                exit; 
       } 

   function subtract($number1,$number2) 
      { 
               $result =$number1 - $number2; 
                echo("The difference of $number1 and $number2 is $result<br><br>"); 
                echo("$number1 &#045 $number2 = $result"); 
                exit; 
       } 

}
class FinancialCalculator extends calculator[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service