Object Oriented Programming using C#

(backadmin) #1
Object Oriented Programming using C#
Object Roles and the Importance of Polymorphism

Note that (myDiscMag is Magazine) would be TRUE because a DiscMag is a Magazine

is can also be used with an interface name on the right, in which case it tests whether the class implements the interface.

Strictly is is testing whether the item on the left is of the type, or a subtype of, the type specified on the right. Doing this
we could extend the CashTill class such that it displays a specific message depending upon the object sold.

public void SaleType (ISaleableItem pSI)
{
if (pSI is Publication)
{
Console.WriteLine(“This is a Publication”);
}
else if (pSI is Ticket)
{
Console.WriteLine (“This is a Ticket”);
}
else
{
Console.WriteLine (“This is a an unknown sale type”);
}
}

Stand out from the crowd
Designed for graduates with less than one year of full-time postgraduate work
experience, London Business School’s Masters in Management will expand your
thinking and provide you with the foundations for a successful career in business.
The programme is developed in consultation with recruiters to provide you with
the key skills that top employers demand. Through 11 months of full-time study,
you will gain the business knowledge and capabilities to increase your career
choices and stand out from the crowd.
Applications are now open for entry in September 2011.
For more information visit http://www.london.edu/mim/
email [email protected] or call +44 (0)20 7000 7573

Masters in Management

London Business School
Regent’s ParkLondon NW1 4SA
United KingdomTel +44 (0)20 7000 7573
Email [email protected]/mim/

Fast-track


your career


Please click the advert

Free download pdf