public void Add(activityGrade obj) { int aggre=0; foreach (activityGrade t in _activityGrade) { if (t.Type2 =="100") { Aggre++; if ((Aggregate >1 ) { throw new Exception(" Only one value of the activityGrade is allowed"); } } } _Grade.Add(obj); }
/// <summary> /// Entry point into console application. /// </summary> static void Main() { // An array of creators Creator[] creators = new Creator[2]; creators[0] = new ID(); creators[1] = new Name(); creators[2] = new activityGrade(); creators[3] = new Evaluation(); // Iterate over creators and create products foreach (Creator creator in creators) { Product product = creator.FactoryMethod(); Console.WriteLine("Created {0}", product.GetType().Name); } // Wait for user Console.ReadKey(); }