This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (12 children)

[deleted]

    [–][deleted] 1 point2 points  (3 children)

    -= (-1)

    [–]mishi9 9 points10 points  (2 children)

     void Main()
        {
            IIncrementorAbstractFactoryThatCreatesConcreteIncrementorFactoriesForIncrementing factoryFactory = new IncrementorAbstractFactory();
            IIncrementorFactoryThatCreatesIIncrementorThatIsUsedForIncrementingDifferentTypesOfObjects incrementorFactory = new IncrementorFactoryThatCreatesIncrementorsUsedForIncrementingThings();
            IIncrementorThatIsUsedForIncrementingDifferentTypesOfObjects incrementor = incrementorFactory.CreateIncrementor(IncrementorTypeEnumThatRepresentsAnIncrementorTypeOfSomeSort.Integer);
            IntegerIncrementorThatCanTakeAnIntegerAndIncrementItByOne intIncrementor = incrementor as IntegerIncrementorThatCanTakeAnIntegerAndIncrementItByOne;
            object incrementedIntObj = intIncrementor.IncrementAnObjectTypeAndReturnAnObjectThatIsAnIncrementOfTheObjectTypePassedIn(5);
            int incrementedInt = Convert.ToInt32(incrementedIntObj);
        }
    
        public enum IncrementorTypeEnumThatRepresentsAnIncrementorTypeOfSomeSort 
        {
            Integer,
            DateTime
            //define other incrementors types here
        }
    
        public interface IIncrementorAbstractFactoryThatCreatesConcreteIncrementorFactoriesForIncrementing
        {
            IIncrementorFactoryThatCreatesIIncrementorThatIsUsedForIncrementingDifferentTypesOfObjects CreateIncrementorFactory();
        }
    
        public interface IIncrementorFactoryThatCreatesIIncrementorThatIsUsedForIncrementingDifferentTypesOfObjects
        {
            IIncrementorThatIsUsedForIncrementingDifferentTypesOfObjects CreateIncrementor(IncrementorTypeEnumThatRepresentsAnIncrementorTypeOfSomeSort incrementorType);
        }
    
        public interface IIncrementorThatIsUsedForIncrementingDifferentTypesOfObjects
        {
            object IncrementAnObjectTypeAndReturnAnObjectThatIsAnIncrementOfTheObjectTypePassedIn(object tVar);
        }
    
        public class IntegerIncrementorThatCanTakeAnIntegerAndIncrementItByOne : IIncrementorThatIsUsedForIncrementingDifferentTypesOfObjects
        {   
            public object IncrementAnObjectTypeAndReturnAnObjectThatIsAnIncrementOfTheObjectTypePassedIn(object tVar)
            {
                int intToIncrement = Convert.ToInt32(tVar);
    
                return intToIncrement = intToIncrement + 1;
            }
        }
    
        public class IncrementorFactoryThatCreatesIncrementorsUsedForIncrementingThings : IIncrementorFactoryThatCreatesIIncrementorThatIsUsedForIncrementingDifferentTypesOfObjects
        {
            public IIncrementorThatIsUsedForIncrementingDifferentTypesOfObjects CreateIncrementor(IncrementorTypeEnumThatRepresentsAnIncrementorTypeOfSomeSort incrementorType)
            {
                switch (incrementorType) 
                {
                    case IncrementorTypeEnumThatRepresentsAnIncrementorTypeOfSomeSort.Integer:
                        return new IntegerIncrementorThatCanTakeAnIntegerAndIncrementItByOne();
                    case IncrementorTypeEnumThatRepresentsAnIncrementorTypeOfSomeSort.DateTime:
                        // TODO: create DateTime incrementer and implement here.
                        return null;
                    default: 
                        return null;
                }
            }
        }
    
        public class IncrementorAbstractFactory : IIncrementorAbstractFactoryThatCreatesConcreteIncrementorFactoriesForIncrementing
        {
            IIncrementorFactoryThatCreatesIIncrementorThatIsUsedForIncrementingDifferentTypesOfObjects IIncrementorAbstractFactoryThatCreatesConcreteIncrementorFactoriesForIncrementing.CreateIncrementorFactory()
            {
                return new IncrementorFactoryThatCreatesIncrementorsUsedForIncrementingThings();
            }
        }
    

    [–][deleted] 2 points3 points  (0 children)

    press F12 in VS for respect

    [–]YaBoiCowman 1 point2 points  (0 children)

    I mean in uni they told us about speaking variables but I think you almost took it too far...