Skip to Content
Head First C#, 3rd Edition
book

Head First C#, 3rd Edition

by Jennifer Greene, Andrew Stellman
September 2013
Beginner content levelBeginner
1098 pages
31h 24m
English
O'Reilly Media, Inc.
Content preview from Head First C#, 3rd Edition

Chapter 6. Inheritance: Your object’s family tree

image with no caption

Sometimes you DO want to be just like your parents.

Ever run across an object that almost does exactly what you want your object to do? Found yourself wishing that if you could just change a few things, that object would be perfect? Well, that’s just one reason that inheritance is one of the most powerful concepts and techniques in the C# language. Before you’re through with this chapter, you’ll learn how to subclass an object to get its behavior, but keep the flexibility to make changes to that behavior. You’ll avoid duplicate code, model the real world more closely, and end up with code that’s easier to maintain.

Kathleen does birthday parties, too

Now that you got your program working, Kathleen is using it all the time. But she doesn’t just handle dinner parties—she does birthdays too, and they’re priced a little differently. She’ll need you to add birthdays to her program.

image with no caption

Brain Power

There’s no healthy option for birthday parties. Can you think of how this could lead to bugs if you start out a project by copying and pasting code from the DinnerParty class from the last chapter?

We need a BirthdayParty class

Modifying your program to calculate the cost of Kathleen’s birthday parties means adding a new class and changing the form to let ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene
Head First C#, 2nd Edition

Head First C#, 2nd Edition

Andrew Stellman, Jennifer Greene
Head First C#, 5th Edition

Head First C#, 5th Edition

Andrew Stellman, Jennifer Greene
Head First C

Head First C

David Griffiths, Dawn Griffiths

Publisher Resources

ISBN: 9781449358846Errata PageSupplemental Content