Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » Implementing a Single Interface(About PHP)
Implementing a Single Interface [message #1719497] Fri, 08 January 2016 11:35
Chinmay Sahoo is currently offline Chinmay SahooFriend
Messages: 1
Registered: January 2016
Junior Member
This section presents a working example of PHP's interface implementation by creating and implementing an interface, named IPillage, that is used to pillage the company:

interface IPillage
{
function emptyBankAccount();
function burnDocuments();
}


This interface is then implemented for use by the Executive class:

class Executive extends Employee implements IPillage
{
private $totalStockOptions;
function emptyBankAccount()
{
echo "Call CFO and ask to transfer funds to Swiss bank account.";
}
function burnDocuments()
{
echo "Torch the office suite.";
}
}


Because pillaging should be carried out at all levels of the company, you can implement the same interface by the Assistant class:

class Assistant extends Employee implements IPillage
{
function takeMemo() {
echo "Taking memo...";
}
function emptyBankAccount()
{
echo "Go on shopping spree with office credit card.";
}
function burnDocuments()
{
echo "Start small fire in the trash can.";
}
}


As you can see, interfaces are particularly useful because, although they define the number and name of the methods required for some behavior to occur, they acknowledge
the fact that different classes might require different ways of carrying out those methods. In this example, the Assistant class burns documents by setting them on fire in a trash can, while the Executive class does so through somewhat more aggressive means (setting the executive's office on fire).
Previous Topic:PDT 3.5
Next Topic:external tool builder stopped working after plugin install
Goto Forum:
  


Current Time: Wed Oct 09 17:05:29 GMT 2024

Powered by FUDForum. Page generated in 0.03345 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top