/// <summary> /// Constructor for the Driver class. Creates a new Driver object with the specified values /// </summary> /// <param name="personality">Enum value indicating the defensiveness/ aggressiveness of a Driver</param> /// <param name="speed">Enum value indicating the speed preference of a Driver</param> /// <param name="attitude">Enum value indicating whether a Driver is calmer or angrier</param> /// <param name="leftLaneOnly">Boolean value whether the Driver only drives in the left lane</param> /// <param name="speedFluctuates">Boolean value whether the Driver's speed fluctuates</param> public Driver(PassingPersonality personality, Speed speed, Attitude attitude, bool leftLaneOnly = false, bool speedFluctuates = false) { Personality = personality; Speed = speed; Attitude = attitude; LeftLaneOnly = leftLaneOnly; SpeedFluctuates = speedFluctuates; }
private double setMergingDistance(PassingPersonality personality) { double mergingGap = 0.0416667; //in case it doesn't get reassigned properly, assign it to the average distance switch (personality) { case PassingPersonality.TIMID: { mergingGap = 0.0719697; //Gap of 380 feet in miles break; } case PassingPersonality.CAUTIOUS: { mergingGap = 0.0568182; //Gap of 300 feet in miles break; } case PassingPersonality.DEFENSIVE: { mergingGap = 0.0416667; //Gap of 220 feet in miles break; } case PassingPersonality.AGGRESSIVE: { mergingGap = 0.0265152; //Gap of 140 feet in miles break; } case PassingPersonality.JERK: { mergingGap = 0.0113636; //Gap of 60 feet in miles break; } } return(mergingGap);; }
/// <summary> /// Assigns the DrivingGap data member a value in feet based on the specified PassingPersonality /// </summary> /// <param name="personality">Enumerated PassingPersonality value indicating level of aggression</param> private void SetDrivingGap(PassingPersonality personality) { DrivingGap = 165; //in case it doesn't get reassigned properly, assign it to the average distance switch (personality) { case PassingPersonality.TIMID: { DrivingGap = 350; //Gap of 350 feet break; } case PassingPersonality.CAUTIOUS: { DrivingGap = 250; //Gap of 250 feet break; } case PassingPersonality.DEFENSIVE: { DrivingGap = 165; //Gap of 165 feet break; } case PassingPersonality.AGGRESSIVE: { DrivingGap = 90; //Gap of 90 feet break; } case PassingPersonality.JERK: { DrivingGap = 25; //Gap of 25 feet break; } } }
public PersonalityHandler(PassingPersonality personality) { requiredMergingGap = setMergingDistance(personality); }
/// <summary> /// Assigns a new level of aggressiveness to a Driver--usually due to an attitude change /// </summary> /// <param name="personality">New level of aggressiveness for the Driver</param> public void SetPersonality(PassingPersonality personality) { Personality = personality; }
/// <summary> /// Constructor for the PersonalityHandler class. Uses SetDrivingGap to assign a driving gap /// based on the Driver's personality /// </summary> /// <param name="personality">Enumerated PassingPersonality value indicating level of aggression</param> public PersonalityHandler(PassingPersonality personality) { SetDrivingGap(personality); }