CHAPTER 14 BUILDING AND CONFIGURING CLASS LIBRARIES
Figure 14-2. Creating a C# class library
The design of your automobile library begins with an abstract base class named Car that defines
various state data via automatic property syntax. This class also has a single abstract method named
TurboBoost(), which makes use of a custom enumeration (EngineState) representing the current
condition of the car’s engine, as seen here:
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
namespace CarLibrary
{
// Represents the state of the engine.
public enum EngineState
{ engineAlive, engineDead }
// The abstract base class in the hierarchy.
public abstract class Car
{
public string PetName {get; set;}
public int CurrentSpeed {get; set;}
public int MaxSpeed {get; set;}
protected EngineState egnState = EngineState.engineAlive;
public EngineState EngineState
{
get { return egnState; }
}
515