//some fields.... public object Clone() { return(new Foo() { Zipcode = Zipcode, StateCode = StateCode, SalesData = SalesData == null ? null : SalesData.Copy(), OtherDataTable = OtherDataTable == null ? null : OtherDataTable.Copy(), VehicleDetails = VehicleDetails.Clone() as VehicleDetails, VehicleCondition = VehicleCondition.Clone() as VehicleCondition, }); }
} //Field setter public object Clone() { var result = new Foo() { _Bar = _Bar, // private members are accessible from their scope, even when object is different Zipcode = Zipcode, StateCode = StateCode, SalesData = SalesData == null ? null : SalesData.Copy(), OtherDataTable = OtherDataTable == null ? null : OtherDataTable.Copy(), VehicleDetails = VehicleDetails.Clone() as VehicleDetails, VehicleCondition = VehicleCondition.Clone() as VehicleCondition, }; // alternatively you can call setter methods result.SetBar(_Bar); return(result); }
public override double CalculatePolicyCover() { if (VehicleCondition.ToLower().Equals("new")) { return(PolicyCover = .90 * VehiclePrice); } else if (VehicleType.ToLower().Equals("good")) { return(PolicyCover = .75 * VehiclePrice); } else if (VehicleType.ToLower().Equals("old")) { return(PolicyCover = .50 * VehiclePrice); } else { return(PolicyCover = 0.0 * VehiclePrice); } }