diff --git a/Espagram.xcodeproj/project.pbxproj b/Espagram.xcodeproj/project.pbxproj index d397e00..70002f2 100644 --- a/Espagram.xcodeproj/project.pbxproj +++ b/Espagram.xcodeproj/project.pbxproj @@ -17,10 +17,26 @@ B506EC7915EBF67500566A27 /* EspagramViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B506EC7815EBF67500566A27 /* EspagramViewController.m */; }; B506ECA515EE898700566A27 /* SpanishConjugator.m in Sources */ = {isa = PBXBuildFile; fileRef = B506ECA415EE898700566A27 /* SpanishConjugator.m */; }; B512F63B164BEC6000DA031E /* EspagramTestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B512F63A164BEC6000DA031E /* EspagramTestViewController.m */; }; - B512F64A164C2A2700DA031E /* Tense.m in Sources */ = {isa = PBXBuildFile; fileRef = B512F649164C2A2700DA031E /* Tense.m */; }; B512F658164D1A0C00DA031E /* EspagramConjugationTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B512F657164D1A0C00DA031E /* EspagramConjugationTableViewController.m */; }; B512F670164D60DB00DA031E /* EspagramMainTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B512F66F164D60DB00DA031E /* EspagramMainTableViewController.m */; }; - B5EFD38C162CA69F00C6E2EB /* GrammarTestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5EFD38B162CA69F00C6E2EB /* GrammarTestViewController.m */; }; + B51F8E21164FF8930033B614 /* Tense.m in Sources */ = {isa = PBXBuildFile; fileRef = B51F8E20164FF8930033B614 /* Tense.m */; }; + B51F8E24165199F80033B614 /* Espagram.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = B51F8E22165199F80033B614 /* Espagram.xcdatamodeld */; }; + B51F8E3916519C850033B614 /* EspagramLessonViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B51F8E3816519C850033B614 /* EspagramLessonViewController.m */; }; + B51F8E4416519D440033B614 /* iPhoneIcon_Small.png in Resources */ = {isa = PBXBuildFile; fileRef = B51F8E4316519D440033B614 /* iPhoneIcon_Small.png */; }; + B51F8E4616519D490033B614 /* iPhoneIcon_Big.png in Resources */ = {isa = PBXBuildFile; fileRef = B51F8E4516519D490033B614 /* iPhoneIcon_Big.png */; }; + B51F8E4816519FE00033B614 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B51F8E4716519FE00033B614 /* CoreData.framework */; }; + B54CFB611652D2A700C0823D /* Lesson+Create.m in Sources */ = {isa = PBXBuildFile; fileRef = B51F8E3C16519D090033B614 /* Lesson+Create.m */; }; + B54CFB6A1652D43900C0823D /* Verb.m in Sources */ = {isa = PBXBuildFile; fileRef = B54CFB691652D43900C0823D /* Verb.m */; }; + B54CFB6D1652D43900C0823D /* Lesson.m in Sources */ = {isa = PBXBuildFile; fileRef = B54CFB6C1652D43900C0823D /* Lesson.m */; }; + B54CFB761652E03600C0823D /* EspagramNewLessonViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B54CFB751652E03600C0823D /* EspagramNewLessonViewController.m */; }; + B56DE15C165412DF00D85DD3 /* EspagramWordsInLessonViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B56DE15B165412DF00D85DD3 /* EspagramWordsInLessonViewController.m */; }; + B56DE160165426B800D85DD3 /* EspagramAddWordToLessonViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B56DE15F165426B800D85DD3 /* EspagramAddWordToLessonViewController.m */; }; + B56DE1631654382500D85DD3 /* Lesson+Conjugator.m in Sources */ = {isa = PBXBuildFile; fileRef = B56DE1621654382500D85DD3 /* Lesson+Conjugator.m */; }; + B56DE1661655769300D85DD3 /* TestableVerb.m in Sources */ = {isa = PBXBuildFile; fileRef = B56DE1651655769300D85DD3 /* TestableVerb.m */; }; + B56DE1691655774E00D85DD3 /* Lesson+Test.m in Sources */ = {isa = PBXBuildFile; fileRef = B56DE1681655774D00D85DD3 /* Lesson+Test.m */; }; + B5A8BB191651A64300C1CC00 /* CoreDataTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5A8BB181651A3E700C1CC00 /* CoreDataTableViewController.m */; }; + B5B3F92D165972EF00E26A40 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = B5B3F92F165972EF00E26A40 /* Localizable.strings */; }; + B5EC6CED1656F1960030C27F /* Verb+Create.m in Sources */ = {isa = PBXBuildFile; fileRef = B5EC6CEC1656F1960030C27F /* Verb+Create.m */; }; B5EFD392162CB18000C6E2EB /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B5EFD391162CB18000C6E2EB /* Default-568h@2x.png */; }; /* End PBXBuildFile section */ @@ -42,16 +58,46 @@ B506ECA415EE898700566A27 /* SpanishConjugator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SpanishConjugator.m; sourceTree = ""; }; B512F639164BEC6000DA031E /* EspagramTestViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EspagramTestViewController.h; sourceTree = ""; }; B512F63A164BEC6000DA031E /* EspagramTestViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EspagramTestViewController.m; sourceTree = ""; }; - B512F648164C2A2700DA031E /* Tense.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tense.h; sourceTree = ""; }; - B512F649164C2A2700DA031E /* Tense.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Tense.m; sourceTree = ""; }; B512F656164D1A0C00DA031E /* EspagramConjugationTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EspagramConjugationTableViewController.h; sourceTree = ""; }; B512F657164D1A0C00DA031E /* EspagramConjugationTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EspagramConjugationTableViewController.m; sourceTree = ""; }; B512F66E164D60DB00DA031E /* EspagramMainTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EspagramMainTableViewController.h; sourceTree = ""; }; B512F66F164D60DB00DA031E /* EspagramMainTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EspagramMainTableViewController.m; sourceTree = ""; }; + B51F8E1F164FF8930033B614 /* Tense.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tense.h; sourceTree = ""; }; + B51F8E20164FF8930033B614 /* Tense.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Tense.m; sourceTree = ""; }; + B51F8E23165199F80033B614 /* Espagram.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Espagram.xcdatamodel; sourceTree = ""; }; + B51F8E3716519C850033B614 /* EspagramLessonViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EspagramLessonViewController.h; sourceTree = ""; }; + B51F8E3816519C850033B614 /* EspagramLessonViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EspagramLessonViewController.m; sourceTree = ""; }; + B51F8E3C16519D090033B614 /* Lesson+Create.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "Lesson+Create.m"; sourceTree = ""; }; + B51F8E4316519D440033B614 /* iPhoneIcon_Small.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = iPhoneIcon_Small.png; sourceTree = ""; }; + B51F8E4516519D490033B614 /* iPhoneIcon_Big.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = iPhoneIcon_Big.png; sourceTree = ""; }; + B51F8E4716519FE00033B614 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; + B54CFB681652D43900C0823D /* Verb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Verb.h; sourceTree = ""; }; + B54CFB691652D43900C0823D /* Verb.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Verb.m; sourceTree = ""; }; + B54CFB6B1652D43900C0823D /* Lesson.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Lesson.h; sourceTree = ""; }; + B54CFB6C1652D43900C0823D /* Lesson.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Lesson.m; sourceTree = ""; }; + B54CFB741652E03600C0823D /* EspagramNewLessonViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EspagramNewLessonViewController.h; sourceTree = ""; }; + B54CFB751652E03600C0823D /* EspagramNewLessonViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EspagramNewLessonViewController.m; sourceTree = ""; }; + B56DE15A165412DF00D85DD3 /* EspagramWordsInLessonViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EspagramWordsInLessonViewController.h; sourceTree = ""; }; + B56DE15B165412DF00D85DD3 /* EspagramWordsInLessonViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EspagramWordsInLessonViewController.m; sourceTree = ""; }; + B56DE15E165426B800D85DD3 /* EspagramAddWordToLessonViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EspagramAddWordToLessonViewController.h; sourceTree = ""; }; + B56DE15F165426B800D85DD3 /* EspagramAddWordToLessonViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EspagramAddWordToLessonViewController.m; sourceTree = ""; }; + B56DE1611654382500D85DD3 /* Lesson+Conjugator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Lesson+Conjugator.h"; sourceTree = ""; }; + B56DE1621654382500D85DD3 /* Lesson+Conjugator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Lesson+Conjugator.m"; sourceTree = ""; }; + B56DE1641655769300D85DD3 /* TestableVerb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestableVerb.h; sourceTree = ""; }; + B56DE1651655769300D85DD3 /* TestableVerb.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestableVerb.m; sourceTree = ""; }; + B56DE1671655774D00D85DD3 /* Lesson+Test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Lesson+Test.h"; sourceTree = ""; }; + B56DE1681655774D00D85DD3 /* Lesson+Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Lesson+Test.m"; sourceTree = ""; }; B58F57661635D27E00CED51B /* Conjugator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Conjugator.h; sourceTree = ""; }; B58F576D16387BE600CED51B /* NSMutableArray_Shuffling.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NSMutableArray_Shuffling.h; path = Espagram/NSMutableArray_Shuffling.h; sourceTree = ""; }; - B5EFD38A162CA69F00C6E2EB /* GrammarTestViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GrammarTestViewController.h; sourceTree = ""; }; - B5EFD38B162CA69F00C6E2EB /* GrammarTestViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GrammarTestViewController.m; sourceTree = ""; }; + B5A8BB171651A3E700C1CC00 /* CoreDataTableViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreDataTableViewController.h; sourceTree = ""; }; + B5A8BB181651A3E700C1CC00 /* CoreDataTableViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CoreDataTableViewController.m; sourceTree = ""; }; + B5A8BB1A1652C39600C1CC00 /* Lesson+Create.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Lesson+Create.h"; sourceTree = ""; }; + B5B3F92E165972EF00E26A40 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = ""; }; + B5B3F930165972F600E26A40 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; + B5B3F931165AC79200E26A40 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; + B5B3F932165AD45400E26A40 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/Localizable.strings; sourceTree = ""; }; + B5EC6CEB1656F1960030C27F /* Verb+Create.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Verb+Create.h"; sourceTree = ""; }; + B5EC6CEC1656F1960030C27F /* Verb+Create.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Verb+Create.m"; sourceTree = ""; }; B5EFD391162CB18000C6E2EB /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -60,6 +106,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + B51F8E4816519FE00033B614 /* CoreData.framework in Frameworks */, B506EC6315EBF67500566A27 /* UIKit.framework in Frameworks */, B506EC6515EBF67500566A27 /* Foundation.framework in Frameworks */, B506EC6715EBF67500566A27 /* CoreGraphics.framework in Frameworks */, @@ -72,6 +119,9 @@ B506EC5315EBF67500566A27 = { isa = PBXGroup; children = ( + B51F8E4716519FE00033B614 /* CoreData.framework */, + B51F8E4516519D490033B614 /* iPhoneIcon_Big.png */, + B51F8E4316519D440033B614 /* iPhoneIcon_Small.png */, B5EFD391162CB18000C6E2EB /* Default-568h@2x.png */, B58F576D16387BE600CED51B /* NSMutableArray_Shuffling.h */, B506EC6815EBF67500566A27 /* Espagram */, @@ -101,25 +151,48 @@ B506EC6815EBF67500566A27 /* Espagram */ = { isa = PBXGroup; children = ( + B54CFB741652E03600C0823D /* EspagramNewLessonViewController.h */, + B54CFB751652E03600C0823D /* EspagramNewLessonViewController.m */, + B5A8BB171651A3E700C1CC00 /* CoreDataTableViewController.h */, + B5A8BB181651A3E700C1CC00 /* CoreDataTableViewController.m */, B506EC7115EBF67500566A27 /* EspagramAppDelegate.h */, B506EC7415EBF67500566A27 /* MainStoryboard.storyboard */, + B56DE15E165426B800D85DD3 /* EspagramAddWordToLessonViewController.h */, + B56DE15F165426B800D85DD3 /* EspagramAddWordToLessonViewController.m */, + B56DE15A165412DF00D85DD3 /* EspagramWordsInLessonViewController.h */, + B56DE15B165412DF00D85DD3 /* EspagramWordsInLessonViewController.m */, + B5EC6CEB1656F1960030C27F /* Verb+Create.h */, + B5EC6CEC1656F1960030C27F /* Verb+Create.m */, + B51F8E3716519C850033B614 /* EspagramLessonViewController.h */, + B51F8E3816519C850033B614 /* EspagramLessonViewController.m */, B512F66E164D60DB00DA031E /* EspagramMainTableViewController.h */, + B51F8E3C16519D090033B614 /* Lesson+Create.m */, + B5A8BB1A1652C39600C1CC00 /* Lesson+Create.h */, B512F66F164D60DB00DA031E /* EspagramMainTableViewController.m */, B512F656164D1A0C00DA031E /* EspagramConjugationTableViewController.h */, B512F657164D1A0C00DA031E /* EspagramConjugationTableViewController.m */, B512F639164BEC6000DA031E /* EspagramTestViewController.h */, B512F63A164BEC6000DA031E /* EspagramTestViewController.m */, - B512F648164C2A2700DA031E /* Tense.h */, - B512F649164C2A2700DA031E /* Tense.m */, B506EC7215EBF67500566A27 /* EspagramAppDelegate.m */, - B5EFD38A162CA69F00C6E2EB /* GrammarTestViewController.h */, - B5EFD38B162CA69F00C6E2EB /* GrammarTestViewController.m */, B506ECA315EE898700566A27 /* SpanishConjugator.h */, B506ECA415EE898700566A27 /* SpanishConjugator.m */, B58F57661635D27E00CED51B /* Conjugator.h */, B506EC7715EBF67500566A27 /* EspagramViewController.h */, B506EC7815EBF67500566A27 /* EspagramViewController.m */, B506EC6915EBF67500566A27 /* Supporting Files */, + B51F8E1F164FF8930033B614 /* Tense.h */, + B51F8E20164FF8930033B614 /* Tense.m */, + B51F8E22165199F80033B614 /* Espagram.xcdatamodeld */, + B54CFB681652D43900C0823D /* Verb.h */, + B54CFB691652D43900C0823D /* Verb.m */, + B54CFB6B1652D43900C0823D /* Lesson.h */, + B54CFB6C1652D43900C0823D /* Lesson.m */, + B56DE1611654382500D85DD3 /* Lesson+Conjugator.h */, + B56DE1621654382500D85DD3 /* Lesson+Conjugator.m */, + B56DE1671655774D00D85DD3 /* Lesson+Test.h */, + B56DE1681655774D00D85DD3 /* Lesson+Test.m */, + B56DE1641655769300D85DD3 /* TestableVerb.h */, + B56DE1651655769300D85DD3 /* TestableVerb.m */, ); path = Espagram; sourceTree = ""; @@ -127,6 +200,7 @@ B506EC6915EBF67500566A27 /* Supporting Files */ = { isa = PBXGroup; children = ( + B5B3F92F165972EF00E26A40 /* Localizable.strings */, B506EC6A15EBF67500566A27 /* Espagram-Info.plist */, B506EC6B15EBF67500566A27 /* InfoPlist.strings */, B506EC6E15EBF67500566A27 /* main.m */, @@ -162,7 +236,7 @@ isa = PBXProject; attributes = { CLASSPREFIX = Espagram; - LastUpgradeCheck = 0440; + LastUpgradeCheck = 0450; ORGANIZATIONNAME = "Abel Fokkinga"; }; buildConfigurationList = B506EC5815EBF67500566A27 /* Build configuration list for PBXProject "Espagram" */; @@ -171,6 +245,9 @@ hasScannedForEncodings = 0; knownRegions = ( en, + nl, + es, + pt, ); mainGroup = B506EC5315EBF67500566A27; productRefGroup = B506EC5F15EBF67500566A27 /* Products */; @@ -190,6 +267,9 @@ B506EC6D15EBF67500566A27 /* InfoPlist.strings in Resources */, B506EC7615EBF67500566A27 /* MainStoryboard.storyboard in Resources */, B5EFD392162CB18000C6E2EB /* Default-568h@2x.png in Resources */, + B51F8E4416519D440033B614 /* iPhoneIcon_Small.png in Resources */, + B51F8E4616519D490033B614 /* iPhoneIcon_Big.png in Resources */, + B5B3F92D165972EF00E26A40 /* Localizable.strings in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -204,11 +284,23 @@ B506EC7315EBF67500566A27 /* EspagramAppDelegate.m in Sources */, B506EC7915EBF67500566A27 /* EspagramViewController.m in Sources */, B506ECA515EE898700566A27 /* SpanishConjugator.m in Sources */, - B5EFD38C162CA69F00C6E2EB /* GrammarTestViewController.m in Sources */, B512F63B164BEC6000DA031E /* EspagramTestViewController.m in Sources */, - B512F64A164C2A2700DA031E /* Tense.m in Sources */, B512F658164D1A0C00DA031E /* EspagramConjugationTableViewController.m in Sources */, B512F670164D60DB00DA031E /* EspagramMainTableViewController.m in Sources */, + B51F8E21164FF8930033B614 /* Tense.m in Sources */, + B51F8E24165199F80033B614 /* Espagram.xcdatamodeld in Sources */, + B51F8E3916519C850033B614 /* EspagramLessonViewController.m in Sources */, + B5A8BB191651A64300C1CC00 /* CoreDataTableViewController.m in Sources */, + B54CFB611652D2A700C0823D /* Lesson+Create.m in Sources */, + B54CFB6A1652D43900C0823D /* Verb.m in Sources */, + B54CFB6D1652D43900C0823D /* Lesson.m in Sources */, + B54CFB761652E03600C0823D /* EspagramNewLessonViewController.m in Sources */, + B56DE15C165412DF00D85DD3 /* EspagramWordsInLessonViewController.m in Sources */, + B56DE160165426B800D85DD3 /* EspagramAddWordToLessonViewController.m in Sources */, + B56DE1631654382500D85DD3 /* Lesson+Conjugator.m in Sources */, + B56DE1661655769300D85DD3 /* TestableVerb.m in Sources */, + B56DE1691655774E00D85DD3 /* Lesson+Test.m in Sources */, + B5EC6CED1656F1960030C27F /* Verb+Create.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -231,6 +323,17 @@ name = MainStoryboard.storyboard; sourceTree = ""; }; + B5B3F92F165972EF00E26A40 /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + B5B3F92E165972EF00E26A40 /* nl */, + B5B3F930165972F600E26A40 /* en */, + B5B3F931165AC79200E26A40 /* es */, + B5B3F932165AD45400E26A40 /* pt */, + ); + name = Localizable.strings; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -256,7 +359,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 5.1; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; SDKROOT = iphoneos; }; name = Debug; @@ -276,7 +379,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 5.1; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; @@ -331,6 +434,19 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCVersionGroup section */ + B51F8E22165199F80033B614 /* Espagram.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + B51F8E23165199F80033B614 /* Espagram.xcdatamodel */, + ); + currentVersion = B51F8E23165199F80033B614 /* Espagram.xcdatamodel */; + path = Espagram.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ }; rootObject = B506EC5515EBF67500566A27 /* Project object */; } diff --git a/Espagram.xcodeproj/project.xcworkspace/xcuserdata/abel.xcuserdatad/UserInterfaceState.xcuserstate b/Espagram.xcodeproj/project.xcworkspace/xcuserdata/abel.xcuserdatad/UserInterfaceState.xcuserstate index 3ccf065..bc52c90 100644 Binary files a/Espagram.xcodeproj/project.xcworkspace/xcuserdata/abel.xcuserdatad/UserInterfaceState.xcuserstate and b/Espagram.xcodeproj/project.xcworkspace/xcuserdata/abel.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Espagram.xcodeproj/project.xcworkspace/xcuserdata/abel.xcuserdatad/WorkspaceSettings.xcsettings b/Espagram.xcodeproj/project.xcworkspace/xcuserdata/abel.xcuserdatad/WorkspaceSettings.xcsettings index 659c876..28f6741 100644 --- a/Espagram.xcodeproj/project.xcworkspace/xcuserdata/abel.xcuserdatad/WorkspaceSettings.xcsettings +++ b/Espagram.xcodeproj/project.xcworkspace/xcuserdata/abel.xcuserdatad/WorkspaceSettings.xcsettings @@ -2,9 +2,21 @@ + BuildLocationStyle + UseAppPreferences + CustomBuildLocationType + RelativeToDerivedData + DerivedDataLocationStyle + Default HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges + IssueFilterStyle + ShowActiveSchemeOnly + LiveSourceIssuesEnabled + SnapshotAutomaticallyBeforeSignificantChanges + SnapshotLocationStyle + Default diff --git a/Espagram.xcodeproj/xcuserdata/abel.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/Espagram.xcodeproj/xcuserdata/abel.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist index 3e56e74..dd1b4a0 100644 --- a/Espagram.xcodeproj/xcuserdata/abel.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist +++ b/Espagram.xcodeproj/xcuserdata/abel.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist @@ -16,5 +16,523 @@ landmarkName = "-getSimplePresentStemVerb:inPerson:" landmarkType = "5"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Espagram.xcodeproj/xcuserdata/abel.xcuserdatad/xcschemes/Espagram.xcscheme b/Espagram.xcodeproj/xcuserdata/abel.xcuserdatad/xcschemes/Espagram.xcscheme index 47148e2..f7f913c 100644 --- a/Espagram.xcodeproj/xcuserdata/abel.xcuserdatad/xcschemes/Espagram.xcscheme +++ b/Espagram.xcodeproj/xcuserdata/abel.xcuserdatad/xcschemes/Espagram.xcscheme @@ -1,6 +1,6 @@ -#import - -@class Conjugations, Tenses, Verbs; - -@interface ConjugatedTense : NSManagedObject - -@property (nonatomic, retain) NSNumber * regularConjugation; -@property (nonatomic, retain) Verbs *verb; -@property (nonatomic, retain) Tenses *tense; -@property (nonatomic, retain) Conjugations *irregularConjugation; - -@end diff --git a/Espagram/ConjugatedTense.m b/Espagram/ConjugatedTense.m deleted file mode 100644 index b84ae35..0000000 --- a/Espagram/ConjugatedTense.m +++ /dev/null @@ -1,22 +0,0 @@ -// -// ConjugatedTense.m -// Espagram -// -// Created by Abel Fokkinga on 8/29/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import "ConjugatedTense.h" -#import "Conjugations.h" -#import "Tenses.h" -#import "Verbs.h" - - -@implementation ConjugatedTense - -@dynamic regularConjugation; -@dynamic verb; -@dynamic tense; -@dynamic irregularConjugation; - -@end diff --git a/Espagram/ConjugatedVerbTableView.h b/Espagram/ConjugatedVerbTableView.h deleted file mode 100644 index c628da9..0000000 --- a/Espagram/ConjugatedVerbTableView.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// ConjugatedVerbTableView.h -// Espagram -// -// Created by Abel Fokkinga on 11/8/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import - -@interface ConjugatedVerbTableView : UITableView - -@end diff --git a/Espagram/ConjugatedVerbTableView.m b/Espagram/ConjugatedVerbTableView.m deleted file mode 100644 index a5a43b6..0000000 --- a/Espagram/ConjugatedVerbTableView.m +++ /dev/null @@ -1,31 +0,0 @@ -// -// ConjugatedVerbTableView.m -// Espagram -// -// Created by Abel Fokkinga on 11/8/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import "ConjugatedVerbTableView.h" - -@implementation ConjugatedVerbTableView - -- (id)initWithFrame:(CGRect)frame -{ - self = [super initWithFrame:frame]; - if (self) { - // Initialization code - } - return self; -} - -/* -// Only override drawRect: if you perform custom drawing. -// An empty implementation adversely affects performance during animation. -- (void)drawRect:(CGRect)rect -{ - // Drawing code -} -*/ - -@end diff --git a/Espagram/Conjugations.h b/Espagram/Conjugations.h deleted file mode 100644 index 9f93f33..0000000 --- a/Espagram/Conjugations.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// Conjugations.h -// Espagram -// -// Created by Abel Fokkinga on 8/29/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import -#import - -@class Persons; - -@interface Conjugations : NSManagedObject - -@property (nonatomic, retain) NSString * root; -@property (nonatomic, retain) NSString * exit; -@property (nonatomic, retain) Persons *conjugationPerson; - -@end diff --git a/Espagram/Conjugations.m b/Espagram/Conjugations.m deleted file mode 100644 index 44bc4bd..0000000 --- a/Espagram/Conjugations.m +++ /dev/null @@ -1,19 +0,0 @@ -// -// Conjugations.m -// Espagram -// -// Created by Abel Fokkinga on 8/29/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import "Conjugations.h" -#import "Persons.h" - - -@implementation Conjugations - -@dynamic root; -@dynamic exit; -@dynamic conjugationPerson; - -@end diff --git a/Espagram/Conjugator.h b/Espagram/Conjugator.h index 1acb3e1..e99efa2 100644 --- a/Espagram/Conjugator.h +++ b/Espagram/Conjugator.h @@ -13,10 +13,13 @@ - (NSDictionary *) persons; +- (NSDictionary *) reflexivePersons; - (NSArray *) personsKeys; - (NSString *) conjugateVerb:(NSString *) verb inPerson:(NSString *) person andTense:(Tense *) tense; +- (NSMutableArray *) getTestConjugationsForVerb:(NSString *) verb inPerson:(NSString *) person andTense:(Tense *) tense; + - (NSString *) description; @end diff --git a/Espagram/CoreDataTableViewController.h b/Espagram/CoreDataTableViewController.h new file mode 100644 index 0000000..0f138b4 --- /dev/null +++ b/Espagram/CoreDataTableViewController.h @@ -0,0 +1,53 @@ +// +// CoreDataTableViewController.h +// +// Created for Stanford CS193p Fall 2011. +// Copyright 2011 Stanford University. All rights reserved. +// +// This class mostly just copies the code from NSFetchedResultsController's documentation page +// into a subclass of UITableViewController. +// +// Just subclass this and set the fetchedResultsController. +// The only UITableViewDataSource method you'll HAVE to implement is tableView:cellForRowAtIndexPath:. +// And you can use the NSFetchedResultsController method objectAtIndexPath: to do it. +// +// Remember that once you create an NSFetchedResultsController, you CANNOT modify its @propertys. +// If you want new fetch parameters (predicate, sorting, etc.), +// create a NEW NSFetchedResultsController and set this class's fetchedResultsController @property again. +// + +#import +#import + +@interface CoreDataTableViewController : UITableViewController + +// The controller (this class fetches nothing if this is not set). +@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController; + +// Causes the fetchedResultsController to refetch the data. +// You almost certainly never need to call this. +// The NSFetchedResultsController class observes the context +// (so if the objects in the context change, you do not need to call performFetch +// since the NSFetchedResultsController will notice and update the table automatically). +// This will also automatically be called if you change the fetchedResultsController @property. +- (void)performFetch; + +// Turn this on before making any changes in the managed object context that +// are a one-for-one result of the user manipulating rows directly in the table view. +// Such changes cause the context to report them (after a brief delay), +// and normally our fetchedResultsController would then try to update the table, +// but that is unnecessary because the changes were made in the table already (by the user) +// so the fetchedResultsController has nothing to do and needs to ignore those reports. +// Turn this back off after the user has finished the change. +// Note that the effect of setting this to NO actually gets delayed slightly +// so as to ignore previously-posted, but not-yet-processed context-changed notifications, +// therefore it is fine to set this to YES at the beginning of, e.g., tableView:moveRowAtIndexPath:toIndexPath:, +// and then set it back to NO at the end of your implementation of that method. +// It is not necessary (in fact, not desirable) to set this during row deletion or insertion +// (but definitely for row moves). +@property (nonatomic) BOOL suspendAutomaticTrackingOfChangesInManagedObjectContext; + +// Set to YES to get some debugging output in the console. +@property BOOL debug; + +@end diff --git a/Espagram/CoreDataTableViewController.m b/Espagram/CoreDataTableViewController.m new file mode 100644 index 0000000..82f511e --- /dev/null +++ b/Espagram/CoreDataTableViewController.m @@ -0,0 +1,175 @@ +// +// CoreDataTableViewController.m +// +// Created for Stanford CS193p Fall 2011. +// Copyright 2011 Stanford University. All rights reserved. +// + +#import "CoreDataTableViewController.h" + +@interface CoreDataTableViewController() +@property (nonatomic) BOOL beganUpdates; +@end + +@implementation CoreDataTableViewController + +#pragma mark - Properties + +@synthesize fetchedResultsController = _fetchedResultsController; +@synthesize suspendAutomaticTrackingOfChangesInManagedObjectContext = _suspendAutomaticTrackingOfChangesInManagedObjectContext; +@synthesize debug = _debug; +@synthesize beganUpdates = _beganUpdates; + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + return YES; +} + +#pragma mark - Fetching + +- (void)performFetch +{ + if (self.fetchedResultsController) { + if (self.fetchedResultsController.fetchRequest.predicate) { + if (self.debug) NSLog(@"[%@ %@] fetching %@ with predicate: %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), self.fetchedResultsController.fetchRequest.entityName, self.fetchedResultsController.fetchRequest.predicate); + } else { + if (self.debug) NSLog(@"[%@ %@] fetching all %@ (i.e., no predicate)", NSStringFromClass([self class]), NSStringFromSelector(_cmd), self.fetchedResultsController.fetchRequest.entityName); + } + NSError *error; + [self.fetchedResultsController performFetch:&error]; + if (error) NSLog(@"[%@ %@] %@ (%@)", NSStringFromClass([self class]), NSStringFromSelector(_cmd), [error localizedDescription], [error localizedFailureReason]); + } else { + if (self.debug) NSLog(@"[%@ %@] no NSFetchedResultsController (yet?)", NSStringFromClass([self class]), NSStringFromSelector(_cmd)); + } + [self.tableView reloadData]; +} + +- (void)setFetchedResultsController:(NSFetchedResultsController *)newfrc +{ + NSFetchedResultsController *oldfrc = _fetchedResultsController; + if (newfrc != oldfrc) { + _fetchedResultsController = newfrc; + newfrc.delegate = self; + if ((!self.title || [self.title isEqualToString:oldfrc.fetchRequest.entity.name]) && (!self.navigationController || !self.navigationItem.title)) { + self.title = newfrc.fetchRequest.entity.name; + } + if (newfrc) { + if (self.debug) NSLog(@"[%@ %@] %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), oldfrc ? @"updated" : @"set"); + [self performFetch]; + } else { + if (self.debug) NSLog(@"[%@ %@] reset to nil", NSStringFromClass([self class]), NSStringFromSelector(_cmd)); + [self.tableView reloadData]; + } + } +} + +#pragma mark - UITableViewDataSource + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return [[self.fetchedResultsController sections] count]; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return [[[self.fetchedResultsController sections] objectAtIndex:section] numberOfObjects]; +} + +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + return [[[self.fetchedResultsController sections] objectAtIndex:section] name]; +} + +- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index +{ + return [self.fetchedResultsController sectionForSectionIndexTitle:title atIndex:index]; +} + +- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView +{ + return [self.fetchedResultsController sectionIndexTitles]; +} + +#pragma mark - NSFetchedResultsControllerDelegate + +- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller +{ + if (!self.suspendAutomaticTrackingOfChangesInManagedObjectContext) { + [self.tableView beginUpdates]; + self.beganUpdates = YES; + } +} + +- (void)controller:(NSFetchedResultsController *)controller + didChangeSection:(id )sectionInfo + atIndex:(NSUInteger)sectionIndex + forChangeType:(NSFetchedResultsChangeType)type +{ + if (!self.suspendAutomaticTrackingOfChangesInManagedObjectContext) + { + switch(type) + { + case NSFetchedResultsChangeInsert: + [self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade]; + break; + + case NSFetchedResultsChangeDelete: + [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade]; + break; + } + } +} + + +- (void)controller:(NSFetchedResultsController *)controller + didChangeObject:(id)anObject + atIndexPath:(NSIndexPath *)indexPath + forChangeType:(NSFetchedResultsChangeType)type + newIndexPath:(NSIndexPath *)newIndexPath +{ + if (!self.suspendAutomaticTrackingOfChangesInManagedObjectContext) + { + switch(type) + { + case NSFetchedResultsChangeInsert: + [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade]; + break; + + case NSFetchedResultsChangeDelete: + [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; + break; + + case NSFetchedResultsChangeUpdate: + [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; + break; + + case NSFetchedResultsChangeMove: + [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; + [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade]; + break; + } + } +} + + +- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller +{ + if (self.beganUpdates) [self.tableView endUpdates]; +} + +- (void)endSuspensionOfUpdatesDueToContextChanges +{ + _suspendAutomaticTrackingOfChangesInManagedObjectContext = NO; +} + +- (void)setSuspendAutomaticTrackingOfChangesInManagedObjectContext:(BOOL)suspend +{ + if (suspend) { + _suspendAutomaticTrackingOfChangesInManagedObjectContext = YES; + } else { + [self performSelector:@selector(endSuspensionOfUpdatesDueToContextChanges) withObject:0 afterDelay:0]; + } +} + +@end + diff --git a/Espagram/Espagram-Info.plist b/Espagram/Espagram-Info.plist index 6e6f80f..df6d18c 100644 --- a/Espagram/Espagram-Info.plist +++ b/Espagram/Espagram-Info.plist @@ -8,10 +8,27 @@ ${PRODUCT_NAME} CFBundleExecutable ${EXECUTABLE_NAME} + CFBundleGetInfoString + + CFBundleIcons + + CFBundlePrimaryIcon + + CFBundleIconFiles + + iPhoneIcon_Small.png + iPhoneIcon_Big.png + + + CFBundleIdentifier com.fokkinga.abel.${PRODUCT_NAME:rfc1034identifier} CFBundleInfoDictionaryVersion 6.0 + CFBundleLocalizations + + en + CFBundleName ${PRODUCT_NAME} CFBundlePackageType @@ -22,8 +39,12 @@ ???? CFBundleVersion 1.0 + LSApplicationCategoryType + LSRequiresIPhoneOS + NSHumanReadableCopyright + Abel Fokkinga UIMainStoryboardFile MainStoryboard UIRequiredDeviceCapabilities diff --git a/Espagram/Espagram.xcdatamodeld/.xccurrentversion b/Espagram/Espagram.xcdatamodeld/.xccurrentversion index 0c67376..d84f9ae 100644 --- a/Espagram/Espagram.xcdatamodeld/.xccurrentversion +++ b/Espagram/Espagram.xcdatamodeld/.xccurrentversion @@ -1,5 +1,8 @@ - + + _XCCurrentVersionName + Espagram.xcdatamodel + diff --git a/Espagram/Espagram.xcdatamodeld/Espagram.xcdatamodel/contents b/Espagram/Espagram.xcdatamodeld/Espagram.xcdatamodel/contents new file mode 100644 index 0000000..5a27510 --- /dev/null +++ b/Espagram/Espagram.xcdatamodeld/Espagram.xcdatamodel/contents @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Espagram/Espagram/ConjugatedTense.h b/Espagram/Espagram/ConjugatedTense.h deleted file mode 100644 index 67353a2..0000000 --- a/Espagram/Espagram/ConjugatedTense.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// ConjugatedTense.h -// Espagram -// -// Created by Abel Fokkinga on 8/29/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import -#import - -@class Conjugations, Tenses, Verbs; - -@interface ConjugatedTense : NSManagedObject - -@property (nonatomic, retain) NSNumber * regularConjugation; -@property (nonatomic, retain) Verbs *verb; -@property (nonatomic, retain) Tenses *tense; -@property (nonatomic, retain) Conjugations *irregularConjugation; - -@end diff --git a/Espagram/Espagram/ConjugatedTense.m b/Espagram/Espagram/ConjugatedTense.m deleted file mode 100644 index b84ae35..0000000 --- a/Espagram/Espagram/ConjugatedTense.m +++ /dev/null @@ -1,22 +0,0 @@ -// -// ConjugatedTense.m -// Espagram -// -// Created by Abel Fokkinga on 8/29/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import "ConjugatedTense.h" -#import "Conjugations.h" -#import "Tenses.h" -#import "Verbs.h" - - -@implementation ConjugatedTense - -@dynamic regularConjugation; -@dynamic verb; -@dynamic tense; -@dynamic irregularConjugation; - -@end diff --git a/Espagram/Espagram/ConjugatedVerbTableView.h b/Espagram/Espagram/ConjugatedVerbTableView.h deleted file mode 100644 index c628da9..0000000 --- a/Espagram/Espagram/ConjugatedVerbTableView.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// ConjugatedVerbTableView.h -// Espagram -// -// Created by Abel Fokkinga on 11/8/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import - -@interface ConjugatedVerbTableView : UITableView - -@end diff --git a/Espagram/Espagram/ConjugatedVerbTableView.m b/Espagram/Espagram/ConjugatedVerbTableView.m deleted file mode 100644 index a5a43b6..0000000 --- a/Espagram/Espagram/ConjugatedVerbTableView.m +++ /dev/null @@ -1,31 +0,0 @@ -// -// ConjugatedVerbTableView.m -// Espagram -// -// Created by Abel Fokkinga on 11/8/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import "ConjugatedVerbTableView.h" - -@implementation ConjugatedVerbTableView - -- (id)initWithFrame:(CGRect)frame -{ - self = [super initWithFrame:frame]; - if (self) { - // Initialization code - } - return self; -} - -/* -// Only override drawRect: if you perform custom drawing. -// An empty implementation adversely affects performance during animation. -- (void)drawRect:(CGRect)rect -{ - // Drawing code -} -*/ - -@end diff --git a/Espagram/Espagram/Conjugations.h b/Espagram/Espagram/Conjugations.h deleted file mode 100644 index 9f93f33..0000000 --- a/Espagram/Espagram/Conjugations.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// Conjugations.h -// Espagram -// -// Created by Abel Fokkinga on 8/29/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import -#import - -@class Persons; - -@interface Conjugations : NSManagedObject - -@property (nonatomic, retain) NSString * root; -@property (nonatomic, retain) NSString * exit; -@property (nonatomic, retain) Persons *conjugationPerson; - -@end diff --git a/Espagram/EspagramAddWordToLessonViewController.h b/Espagram/EspagramAddWordToLessonViewController.h new file mode 100644 index 0000000..90986f4 --- /dev/null +++ b/Espagram/EspagramAddWordToLessonViewController.h @@ -0,0 +1,36 @@ +// +// EspagramAddWordToLessonViewController.h +// Espagram +// +// Created by Abel Fokkinga on 11/14/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import + +@class EspagramAddWordToLessonViewController; +@protocol EspagramAddWordToLessonViewControllerDelegate + +- (void) addWord:(NSString *)word withMeaning:(NSString *)meaning; + +- (void) cancelAddingWord; + +@end + +@interface EspagramAddWordToLessonViewController : UIViewController + +@property (weak, nonatomic) IBOutlet UILabel *wordLabel; + +@property (weak, nonatomic) IBOutlet UILabel *meaningLabel; + +@property (weak, nonatomic) IBOutlet UIButton *addButton; + +@property (weak, nonatomic) IBOutlet UIButton *cancelButton; + +@property (weak, nonatomic) IBOutlet UITextField *wordInputText; + +@property (weak, nonatomic) IBOutlet UITextField *meaningInputText; + +@property (nonatomic,strong) id dataSource; + +@end diff --git a/Espagram/EspagramAddWordToLessonViewController.m b/Espagram/EspagramAddWordToLessonViewController.m new file mode 100644 index 0000000..30f09c6 --- /dev/null +++ b/Espagram/EspagramAddWordToLessonViewController.m @@ -0,0 +1,52 @@ +// +// EspagramAddWordToLessonViewController.m +// Espagram +// +// Created by Abel Fokkinga on 11/14/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import "EspagramAddWordToLessonViewController.h" + +@interface EspagramAddWordToLessonViewController () + +@end + +@implementation EspagramAddWordToLessonViewController + +@synthesize dataSource = _dataSource; +@synthesize wordLabel = _wordLabel; +@synthesize meaningLabel = _meaningLabel; +@synthesize wordInputText = _wordInputText; +@synthesize meaningInputText = _meaningInputText; +@synthesize addButton = _addButton; +@synthesize cancelButton = _cancelButton; + +- (IBAction)editingDidEnd { + [self resignFirstResponder]; +} + + +- (IBAction)addButtonPressed:(id)sender { + [self.dataSource addWord: self.wordInputText.text withMeaning:self.meaningInputText.text]; +} + +- (IBAction)cancelButtonPressed:(id)sender { + [self.dataSource cancelAddingWord]; +} + + +- (void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + + self.wordLabel.text = NSLocalizedString(@"New verb", @"Adding a new verb to a lesson"); + self.meaningLabel.text = NSLocalizedString(@"Meaning", @"Adding the meaning of a new verb being added to a lesson"); + + [self.addButton setTitle:NSLocalizedString(@"Add Verb", @"Add button when adding a verb to a lesson") forState:UIControlStateNormal]; + + [self.cancelButton setTitle:NSLocalizedString(@"Cancel Verb",@"Cancel button to cancel adding a verb to a lesson") forState:UIControlStateNormal]; +} + + +@end diff --git a/Espagram/EspagramAppDelegate.m b/Espagram/EspagramAppDelegate.m index b7e78dc..7589d8e 100644 --- a/Espagram/EspagramAppDelegate.m +++ b/Espagram/EspagramAppDelegate.m @@ -43,4 +43,6 @@ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } + + @end diff --git a/Espagram/EspagramConjugationTableViewController.h b/Espagram/EspagramConjugationTableViewController.h index da5254b..e23a321 100644 --- a/Espagram/EspagramConjugationTableViewController.h +++ b/Espagram/EspagramConjugationTableViewController.h @@ -7,24 +7,12 @@ // #import -#import "Conjugator.h" - -@class EspagramConjugationTableViewController; - -@protocol EspagramConjugationTableView - -@property (strong, nonatomic) id conjugator; -@property (strong, nonatomic) Tense *tense; -@property (strong, nonatomic) NSString* verb; - -@end +#import "SpanishConjugator.h" +#import "Lesson+Conjugator.h" +#import "Verb.h" @interface EspagramConjugationTableViewController : UITableViewController -@property (weak, nonatomic) IBOutlet UITextField *verbInput; - -@property (nonatomic, strong) id dataSource; - -- (void) reloadData; +@property (weak, nonatomic) IBOutlet Verb *verb; @end diff --git a/Espagram/EspagramConjugationTableViewController.m b/Espagram/EspagramConjugationTableViewController.m index c370050..f218a03 100644 --- a/Espagram/EspagramConjugationTableViewController.m +++ b/Espagram/EspagramConjugationTableViewController.m @@ -14,40 +14,8 @@ @implementation EspagramConjugationTableViewController -@synthesize dataSource = _dataSource; +@synthesize verb = _verb; -- (void) dataSource:(id ) dataSource { - _dataSource = dataSource; - [self reloadData]; -} - -- (IBAction)verbEntered:(id)sender { - [self.view resignFirstResponder]; -} - -- (id)initWithStyle:(UITableViewStyle)style -{ - self = [super initWithStyle:style]; - if (self) { - // Custom initialization - } - return self; -} - -- (void) reloadData { - if (_dataSource) { - NSLog(@"language %@", [self.dataSource.conjugator description]); - NSLog(@"persons %d", self.dataSource.conjugator.persons.count); - [self.tableView reloadData]; - } else NSLog(@"Datasource is nil"); -} - - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} #pragma mark - Table view data source @@ -55,12 +23,11 @@ { return 1; } - - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. - return [[[self.dataSource conjugator] persons] count]; + return [[[self.verb.lesson getConjugationEngine] persons] count]; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section @@ -69,7 +36,7 @@ switch (section) { case 0: - sectionName = self.dataSource.verb; + sectionName = self.verb.verb; break; default: sectionName = @""; @@ -88,20 +55,20 @@ } - NSString * person = [[self.dataSource.conjugator personsKeys] objectAtIndex:indexPath.row]; - cell.textLabel.text = [self.dataSource.conjugator.persons objectForKey:person]; - cell.detailTextLabel.text = [self.dataSource.conjugator conjugateVerb:self.dataSource.verb inPerson:person andTense:self.dataSource.tense]; + NSString * person = [[[self.verb.lesson getConjugationEngine] personsKeys] objectAtIndex:indexPath.row]; + cell.textLabel.text = [[[self.verb.lesson getConjugationEngine] persons] objectForKey:person]; + cell.detailTextLabel.text = [[self.verb.lesson getConjugationEngine] conjugateVerb:self.verb.verb inPerson:person andTense:[self.verb.lesson getTenseAsTense]]; return cell; } -- (void)viewDidLoad +- (void) viewDidAppear:(BOOL)animated { - [self.tableView reloadData]; + [super viewDidAppear:animated]; + self.title = [[self.verb.lesson getTenseAsTense] getTenseInLanguage:self.verb.lesson.conjugator]; + } - - #pragma mark - Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath diff --git a/Espagram/EspagramLessonViewController.h b/Espagram/EspagramLessonViewController.h new file mode 100644 index 0000000..7f7e8ce --- /dev/null +++ b/Espagram/EspagramLessonViewController.h @@ -0,0 +1,24 @@ +// +// EspagramLessonViewController.h +// Espagram +// +// Created by Abel Fokkinga on 11/12/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import +#import "CoreDataTableViewController.h" +#import "Conjugator.h" +#import "EspagramNewLessonViewController.h" +#import "Tense.h" + + +@interface EspagramLessonViewController : CoreDataTableViewController + +@property (nonatomic, strong) UIManagedDocument * lessonsDatabase; +@property (nonatomic, strong) +id conjugator; +@property (nonatomic, strong) +Tense * tense; + +@end diff --git a/Espagram/EspagramLessonViewController.m b/Espagram/EspagramLessonViewController.m new file mode 100644 index 0000000..f80dfd0 --- /dev/null +++ b/Espagram/EspagramLessonViewController.m @@ -0,0 +1,225 @@ +// +// EspagramLessonViewController.m +// Espagram +// +// Created by Abel Fokkinga on 11/12/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import "EspagramLessonViewController.h" +#import "Lesson+Create.h" +#import "Lesson+Conjugator.h" +#import "EspagramTestViewController.h" + + +@interface EspagramLessonViewController () +@end + +@implementation EspagramLessonViewController + +@synthesize lessonsDatabase = _lessonsDatabase; +@synthesize conjugator = _conjugator; +@synthesize tense = _tense; + + +- (IBAction)addLessonButtonPressed:(id)sender { + [self performSegueWithIdentifier:@"Add new Lesson" sender:self]; +} + +- (void) addLesson:(NSString*)title withDescription:(NSString*) subTitle { + + NSLog(@"Need to dismiss modal view controller"); + [[self presentedViewController] dismissViewControllerAnimated:TRUE completion:^{ + NSLog(@"View controller dismissed"); + }]; + + NSLog(@"database %@, context %@", self.lessonsDatabase,[self.lessonsDatabase managedObjectContext]); + + [Lesson addLessonWithTitle:title andSubTitle:subTitle inTense:self.tense conjugatedBy:self.conjugator inManagedObjectContext:[self.lessonsDatabase managedObjectContext]]; + + [self.lessonsDatabase saveToURL:self.lessonsDatabase.fileURL forSaveOperation:UIDocumentSaveForOverwriting completionHandler:NULL]; +} + +- (void) cancelLesson{ + NSLog(@"Cancel pressed, need to dismiss modal view controller"); + [[self presentedViewController] dismissViewControllerAnimated:TRUE completion:^{ + NSLog(@"View controller dismissed"); + }]; +} + + + + +#pragma mark - View lifecycle + + +- (void) setupFetchedResultsController{ + NSFetchRequest *request = [[NSFetchRequest alloc] initWithEntityName:@"Lesson"]; + + self.debug = TRUE; + + // Where clause + request.predicate = [NSCompoundPredicate andPredicateWithSubpredicates:[NSArray arrayWithObjects:[NSPredicate predicateWithFormat:@"tense = %@", self.tense.tense], [NSPredicate predicateWithFormat:@"conjugator = %@", [self.conjugator description]],nil]]; + + + request.sortDescriptors = [[NSArray alloc] initWithObjects:[[NSSortDescriptor alloc] initWithKey:@"title" ascending:TRUE], nil]; + + self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:self.lessonsDatabase.managedObjectContext sectionNameKeyPath:nil cacheName:nil]; +} + +- (void) createDocument +{ + [self.lessonsDatabase saveToURL:self.lessonsDatabase.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL succes){ + NSLog(@"Created lessons database"); + }]; + +} + + +- (void) useDocument +{ + if (![[NSFileManager defaultManager] fileExistsAtPath:[self.lessonsDatabase.fileURL path]]) { + [self createDocument]; + [self fetchedResultsController]; + } else if (self.lessonsDatabase.documentState == UIDocumentStateClosed){ + [self.lessonsDatabase openWithCompletionHandler:^(BOOL succes){ + NSLog(@"Opened lessons database"); + [self setupFetchedResultsController]; + }]; + } else if (self.lessonsDatabase.documentState == UIDocumentStateNormal) { + [self setupFetchedResultsController]; + } + +} + + +- (void) setLessonsDatabase:(UIManagedDocument *)lessonsDatabase{ + if ( _lessonsDatabase != lessonsDatabase ) { + _lessonsDatabase = lessonsDatabase; + [self useDocument]; + } + +} + +- (void)viewWillAppear:(BOOL)animated{ + + [super viewWillAppear:animated]; + + self.title = NSLocalizedString(@"Lessons title",@"Lessons title"); + + if (!self.lessonsDatabase) { // We'll create a default database if none is set + NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDirectory] lastObject]; + url = [url URLByAppendingPathComponent:@"Default Espagram database"]; + + UIManagedDocument *doc = [[UIManagedDocument alloc] initWithFileURL:url]; + NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, + [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; + doc.persistentStoreOptions = options; + self.lessonsDatabase = doc; + } + +} + + +- (void)viewDidUnload { + + [super viewDidUnload]; + + [self.lessonsDatabase closeWithCompletionHandler:^(BOOL success) { + NSLog(@"Database closed"); + }]; +} + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *CellIdentifier = @"Lesson cell"; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; + + Lesson *lesson = [self.fetchedResultsController objectAtIndexPath:indexPath]; + NSLog(@"Showing lesson: %@", lesson.title); + cell.textLabel.text = lesson.title; + cell.detailTextLabel.text = lesson.subTitle; + + return cell; +} + +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + NSIndexPath * indexPath = [self.tableView indexPathForCell:sender]; + Lesson * lesson = [self.fetchedResultsController objectAtIndexPath:indexPath]; + + if ( [segue.identifier isEqualToString:@"Testing"]){ + NSLog(@"Preparing for segue Testing"); + + if ([segue.destinationViewController respondsToSelector:@selector(setConjugator:)]) { + [segue.destinationViewController setConjugator:self.conjugator]; + } + + + if ([segue.destinationViewController respondsToSelector:@selector(setLesson:)]) { + [segue.destinationViewController setLesson:lesson]; + [segue.destinationViewController setTitle:lesson.title]; + } + } + + if ( [segue.identifier isEqualToString:@"Add new Lesson"]){ + NSLog(@"Preparing for segue Add new Lesson"); + [segue.destinationViewController setDataSource:self]; + } + + if ( [segue.identifier isEqualToString:@"Show Words In Lesson"]){ + NSLog(@"Preparing for segue Show Words In Lesson"); + if ([segue.destinationViewController respondsToSelector:@selector(setLesson:)]) { + [segue.destinationViewController setLesson:lesson]; + } + } +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + Lesson * lesson = [self.fetchedResultsController objectAtIndexPath:indexPath]; + + if ( [lesson.verbs count] == 0) { + // Lesson contains no words yet.. so go to the WordsInLessonView to add them + // sender is the selected cell + [self performSegueWithIdentifier:@"Show Words In Lesson" sender:[self.tableView cellForRowAtIndexPath:indexPath]]; + } else { + [self performSegueWithIdentifier:@"Testing" sender:[self.tableView cellForRowAtIndexPath:indexPath]]; + } + + +} + +- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath +{ + [self performSegueWithIdentifier:@"Show Words In Lesson" sender:[self.tableView cellForRowAtIndexPath:indexPath]]; +} + +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath +{ + // Return NO if you do not want the specified item to be editable. + return YES; +} + + + +// Override to support editing the table view. +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + //[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + Lesson * selectedLesson = [self.fetchedResultsController objectAtIndexPath:indexPath]; + [[self.lessonsDatabase managedObjectContext] deleteObject:selectedLesson]; + } + // else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + // } +} + + + +@end diff --git a/Espagram/EspagramMainTableViewController.h b/Espagram/EspagramMainTableViewController.h index 3e040d4..8f7ed8f 100644 --- a/Espagram/EspagramMainTableViewController.h +++ b/Espagram/EspagramMainTableViewController.h @@ -10,4 +10,7 @@ @interface EspagramMainTableViewController : UITableViewController + +@property (weak, nonatomic) IBOutlet UIBarButtonItem *aboutButton; + @end diff --git a/Espagram/EspagramMainTableViewController.m b/Espagram/EspagramMainTableViewController.m index 219f00a..e0d3e55 100644 --- a/Espagram/EspagramMainTableViewController.m +++ b/Espagram/EspagramMainTableViewController.m @@ -9,6 +9,7 @@ #import "EspagramMainTableViewController.h" #import "SpanishConjugator.h" #import "EspagramTestViewController.h" +#import "EspagramLessonViewController.h" @interface EspagramMainTableViewController () @property (nonatomic, strong) NSString *language, *displayTitle; @@ -20,6 +21,7 @@ @synthesize language = _language; @synthesize tense = _tense; @synthesize displayTitle = _displayTitle; +@synthesize aboutButton = _aboutButton; - (id)initWithStyle:(UITableViewStyle)style { @@ -30,22 +32,13 @@ return self; } -- (void)viewDidLoad +- (void)viewDidAppear:(BOOL)animated { - [super viewDidLoad]; - - // Uncomment the following line to preserve selection between presentations. - // self.clearsSelectionOnViewWillAppear = NO; - - // Uncomment the following line to display an Edit button in the navigation bar for this view controller. - // self.navigationItem.rightBarButtonItem = self.editButtonItem; + [super viewDidAppear:animated]; + + [self.aboutButton setTitle:NSLocalizedString(@"About button", @"About button text")]; } -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} # pragma mark - Espagram setters and getters @@ -66,18 +59,16 @@ self.tense = [[Tense alloc] init]; self.tense.tense = tense; self.displayTitle = [self.tense getTenseInLanguage:@"Spanish"]; - [self performSegueWithIdentifier:@"Testing" sender:self]; + [self performSegueWithIdentifier:@"Show Lessons" sender:self]; } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - if ( [segue.identifier isEqualToString:@"Testing"]) { - EspagramTestViewController * dest = segue.destinationViewController; - dest.title = self.displayTitle; - dest.conjugator= [self getLanguage]; - dest.tense =self.tense; + if ( [segue.identifier isEqualToString:@"Show Lessons"]) { + [segue.destinationViewController setConjugator:[self getLanguage]]; + [segue.destinationViewController setTense:self.tense]; } } @@ -124,30 +115,39 @@ } */ + #pragma mark - Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString * selectedTense = [tableView cellForRowAtIndexPath:indexPath].textLabel.text; NSLog(@"Selected tense: %@", selectedTense); - - if ( [selectedTense isEqualToString:@"Presente de indicativo"] ) { + + if ( [selectedTense isEqualToString:@"Presente de Indicativo"] ) { [self testVerbsWithLanguage: @"Spanish" andTense:@"SIMPLE_PRESENT"]; - } else if ( [selectedTense isEqualToString:@"Indefinido"] ) { + } else if ( [selectedTense isEqualToString:@"Presente de Subjuntivo"] ) { + [self testVerbsWithLanguage: @"Spanish" andTense:@"PRESENT_SUBJUNCTIVE"]; + } else if ( [selectedTense isEqualToString:@"Pretérito Indefinido"] ) { [self testVerbsWithLanguage: @"Spanish" andTense:@"SIMPLE_PAST"]; } else if ( [selectedTense isEqualToString:@"Imperfecto"] ) { [self testVerbsWithLanguage: @"Spanish" andTense:@"IMPERFECT"]; + } else if ( [selectedTense isEqualToString:@"Imperfecto de Subjuntivo"] ) { + [self testVerbsWithLanguage: @"Spanish" andTense:@"IMPERFECT_SUBJUNCTIVE"]; } else if ( [selectedTense isEqualToString:@"Futuro"] ) { [self testVerbsWithLanguage: @"Spanish" andTense:@"FUTURE"]; } else if ( [selectedTense isEqualToString:@"Pretérito Perfecto"] ) { [self testVerbsWithLanguage: @"Spanish" andTense:@"PRESENT_PERFECT"]; + } else if ( [selectedTense isEqualToString:@"Perfecto de Subjuntivo"] ) { + [self testVerbsWithLanguage: @"Spanish" andTense:@"PERFECT_SUBJUNCTIVE"]; } else if ( [selectedTense isEqualToString:@"Pluscuamperfecto"] ) { [self testVerbsWithLanguage: @"Spanish" andTense:@"PAST_PERFECT"]; + } else if ( [selectedTense isEqualToString:@"Pluscuamperfecto Subjuntivo"] ) { + [self testVerbsWithLanguage: @"Spanish" andTense:@"PAST_PERFECT_SUBJUNCTIVE"]; } else if ( [selectedTense isEqualToString:@"Futuro Perfecto"] ) { [self testVerbsWithLanguage: @"Spanish" andTense:@"FUTURE_PERFECT"]; } else if ( [selectedTense isEqualToString:@"Condicional"] ) { [self testVerbsWithLanguage: @"Spanish" andTense:@"CONDITIONAL"]; - } else if ( [selectedTense isEqualToString:@"Condicional Perfect"] ) { + } else if ( [selectedTense isEqualToString:@"Condicional Perfecto"] ) { [self testVerbsWithLanguage: @"Spanish" andTense:@"CONDITIONAL_PERFECT"]; } else if ( [selectedTense isEqualToString:@"Gerundio"] ) { [self testVerbsWithLanguage: @"Spanish" andTense:@"GERUND"]; diff --git a/Espagram/EspagramNewLessonViewController.h b/Espagram/EspagramNewLessonViewController.h new file mode 100644 index 0000000..b6714f0 --- /dev/null +++ b/Espagram/EspagramNewLessonViewController.h @@ -0,0 +1,34 @@ +// +// EspagramNewLessonViewController.h +// Espagram +// +// Created by Abel Fokkinga on 11/13/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import + +@class EspagramConjugationTableViewController; + +@protocol EspagramNewLessonDelegate +- (void) addLesson:(NSString*)title withDescription:(NSString*) subTitle; +- (void) cancelLesson; +@end + +@interface EspagramNewLessonViewController : UIViewController + +@property (weak, nonatomic) IBOutlet UILabel *nameLabel; + +@property (weak, nonatomic) IBOutlet UILabel *descriptionLabel; + +@property (weak, nonatomic) IBOutlet UIButton *addButton; + +@property (weak, nonatomic) IBOutlet UIButton *cancelButton; + +@property (weak, nonatomic) IBOutlet UITextField *lessonNameTextInput; + +@property (weak, nonatomic) IBOutlet UITextField *lessonDescriptionTextInput; + +@property (nonatomic,strong) id dataSource; + +@end diff --git a/Espagram/EspagramNewLessonViewController.m b/Espagram/EspagramNewLessonViewController.m new file mode 100644 index 0000000..59c9148 --- /dev/null +++ b/Espagram/EspagramNewLessonViewController.m @@ -0,0 +1,70 @@ +// +// EspagramNewLessonViewController.m +// Espagram +// +// Created by Abel Fokkinga on 11/13/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import "EspagramNewLessonViewController.h" + +@interface EspagramNewLessonViewController () + +@end + +@implementation EspagramNewLessonViewController + +@synthesize nameLabel = _nameLabel; +@synthesize descriptionLabel = _descriptionLabel; +@synthesize addButton = _addButton; +@synthesize lessonDescriptionTextInput = _lessonDescriptionTextInput; +@synthesize lessonNameTextInput = _lessonNameTextInput; +@synthesize dataSource = _dataSource; + +- (IBAction)editingDidEnd:(id)sender { + [self resignFirstResponder]; +} + +- (IBAction)addButtonPressed { + NSLog(@"Add button pressed with %@", self.lessonNameTextInput.text); + [self.dataSource addLesson:self.lessonNameTextInput.text withDescription:self.lessonDescriptionTextInput.text]; +} + +- (IBAction)cancelButtonPressed:(id)sender { + if ( !self.dataSource ) { + NSLog(@"dataSource is not set"); + } + NSLog(@"Cancel button pressed"); + [self.dataSource cancelLesson]; +} + + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + + self.nameLabel.text = NSLocalizedString(@"Lesson title", @"Lesson title when adding a new lesson"); + self.descriptionLabel.text = NSLocalizedString(@"Description", @"Lesson description when adding a new lesson"); + + [self.addButton setTitle:NSLocalizedString(@"Add Lesson","Add button for adding a new lesson") forState:UIControlStateNormal]; + + [self.cancelButton setTitle:NSLocalizedString(@"Cancel Lesson","Cancel button when adding a new lesson") forState:UIControlStateNormal]; + +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +@end diff --git a/Espagram/EspagramTestViewController.h b/Espagram/EspagramTestViewController.h index 4447f92..0b046fb 100644 --- a/Espagram/EspagramTestViewController.h +++ b/Espagram/EspagramTestViewController.h @@ -9,9 +9,29 @@ #import #import "Conjugator.h" #import "EspagramConjugationTableViewController.h" +#import "Lesson+Conjugator.h" +#import "Lesson+Test.h" +#import "Verb.h" -@interface EspagramTestViewController : UIViewController +@interface EspagramTestViewController : UIViewController -@property (weak, nonatomic) IBOutlet UITextField *verbInput; +@property (weak, nonatomic) IBOutlet UILabel *testedVerbLabel; + +@property (weak, nonatomic) IBOutlet UILabel *verbMeaningLable; + +@property (weak, nonatomic) IBOutlet UILabel *verbPersonLabel; + +@property (weak, nonatomic) IBOutlet UIButton *answer1Button; + +@property (weak, nonatomic) IBOutlet UIButton *answer2Button; + +@property (weak, nonatomic) IBOutlet UIButton *answer3Button; + +@property (weak, nonatomic) IBOutlet UIButton *answer4Button; + +@property (weak, nonatomic) IBOutlet UIButton *nextButton; + + +@property (strong, nonatomic) Lesson *lesson; @end diff --git a/Espagram/EspagramTestViewController.m b/Espagram/EspagramTestViewController.m index aeb7745..0c2b62b 100644 --- a/Espagram/EspagramTestViewController.m +++ b/Espagram/EspagramTestViewController.m @@ -7,55 +7,191 @@ // #import "EspagramTestViewController.h" +#import "NSMutableArray_Shuffling.h" @interface EspagramTestViewController () +@property (nonatomic, strong) NSMutableArray * testSet; +@property (nonatomic, strong) TestableVerb * currentVerb; +@property (nonatomic) int correctAnswersInCurrentSet; +@property (nonatomic) int wrongAnswersInCurrentSet; + @end @implementation EspagramTestViewController -@synthesize conjugator = _conjugator; -@synthesize tense = _tense; -@synthesize verb = _verb; -@synthesize verbInput; +@synthesize lesson = _lesson; +@synthesize testedVerbLabel = _testedVerbLabel; +@synthesize verbMeaningLable = _testedVerbLable; +@synthesize verbPersonLabel = _verbPersonLabel; +@synthesize answer1Button = _answer1Button; +@synthesize answer2Button = _answer2Button; +@synthesize answer3Button = _answer3Button; +@synthesize answer4Button = _answer4Button; +@synthesize nextButton = _nextButton; +@synthesize testSet = _testSet; +@synthesize currentVerb = _currentVerb; +@synthesize correctAnswersInCurrentSet = _correctAnswersInCurrentSet; +@synthesize wrongAnswersInCurrentSet = _wrongAnswersInCurrentSet; + + +- (NSMutableArray *)testSet{ + // Check if there are any verbs in the set + if ( _testSet.count == 0) { + _testSet = [self.lesson testableVerbs]; + self.correctAnswersInCurrentSet = 0; + self.wrongAnswersInCurrentSet = 0; + } + return _testSet; +}; -- (NSString *) verb { - if ( self.verbInput.text) - _verb = self.verbInput.text; - return _verb; -} - (IBAction)EditingDidEnd:(UITextField *)sender { [self resignFirstResponder]; } -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil -{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - // Custom initialization - } - return self; -} -- (void)viewDidLoad -{ - [super viewDidLoad]; - // Do any additional setup after loading the view. -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - - -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { +- (IBAction)answered:(UIButton *)sender { - if ( [segue.identifier isEqualToString:@"Conjugate"]) { - [segue.destinationViewController setDataSource:self]; - [segue.destinationViewController setTitle:[self.tense getTenseInLanguage:[self.conjugator description]]]; + NSString * correctAnswer = [self.lesson.getConjugationEngine conjugateVerb:self.currentVerb.verb.verb inPerson:self.currentVerb.person andTense:[self.lesson getTenseAsTense]]; + + + if ( [sender.titleLabel.text isEqualToString:correctAnswer]) { + + [self setUILabelTitle:self.verbPersonLabel withText:[[[[[[self.lesson getConjugationEngine] persons] objectForKey:self.currentVerb.person] stringByAppendingString:@" "] stringByAppendingString:correctAnswer] stringByAppendingString:@" \u2705"] inColour:[UIColor greenColor] andSize:16]; + + } else { + [self setUILabelTitle:self.verbPersonLabel withText:[[[[[[self.lesson getConjugationEngine] persons] objectForKey:self.currentVerb.person] stringByAppendingString:@" "] stringByAppendingString:sender.titleLabel.text] stringByAppendingString:@" \u274C"] inColour:[UIColor redColor] andSize:16]; + + // Set current test verb to failed + self.currentVerb.failed = true; } } +- (id) popLastFromArray:(NSMutableArray *)a +{ + id lastObject = nil; + if ( a && a.count > 0 ) { + lastObject = [a lastObject]; + NSLog(@"Popping: %@", lastObject); + [a removeLastObject]; + } + return lastObject; +} + +- (IBAction)nextButtonPressed:(id)sender { + + [self.testSet removeLastObject]; + + [self nextVerb]; +} + +- (void)setAnswerButton:(UIButton *)button withAnswer:(NSString *)answer andCorrect:(NSString *)correct +{ + + [self setUIButtonTitle:button withText:answer inColour:[UIColor blackColor] forState:UIControlStateNormal]; + + if ( [answer isEqualToString:correct]) + [self setUIButtonTitle:button withText:answer inColour:[UIColor greenColor] forState:UIControlStateHighlighted]; + else + [self setUIButtonTitle:button withText:answer inColour:[UIColor greenColor] forState:UIControlStateHighlighted]; +} + +- (void) setUIButtonTitle:(UIButton *)button withText:(NSString *) titleString inColour:(UIColor *) colour forState:(UIControlState)controlState +{ + NSAttributedString *title; + title = [[NSAttributedString alloc] initWithString:titleString attributes:@{ NSFontAttributeName : + [UIFont fontWithName:@"Noteworthy-Bold" size:16], + // NSUnderlineStyleAttributeName : @1, + NSStrokeColorAttributeName : colour}]; + + [button setAttributedTitle:title forState:controlState]; + +} + +- (void) setUILabelTitle:(UILabel *)label withText:(NSString *) titleString inColour:(UIColor *) colour andSize:(int) fontSize; +{ + NSAttributedString *title; + title = [[NSAttributedString alloc] initWithString:titleString attributes:@{ NSFontAttributeName : + [UIFont fontWithName:@"Noteworthy-Bold" size:fontSize], + // NSUnderlineStyleAttributeName : @1, + NSStrokeColorAttributeName : colour + }]; + + label.attributedText = title; +} + + +- (void) nextVerb { + NSMutableArray * answers; + + if ( self.currentVerb && self.currentVerb.failed) { + // Last test failed.. so we won't remove it + // instead we shuffle the test set. + [self.testSet shuffle]; + + // increase wrongly answered counter + self.wrongAnswersInCurrentSet += 1; + } { + // Last verb answered correctly + [self.testSet lastObject]; + + // increase wrongly answered counter + self.correctAnswersInCurrentSet += 1; + } + + self.currentVerb = self.testSet.lastObject; + + + if ( self.currentVerb) { + + NSLog(@"Testing verb %@ in %@", self.currentVerb.verb.verb, self.currentVerb.person); + + NSString * correctAnswer = [self.lesson.getConjugationEngine conjugateVerb:self.currentVerb.verb.verb inPerson:self.currentVerb.person andTense:[self.lesson getTenseAsTense]]; + + NSLog(@"Correct answer: %@", correctAnswer); + + // Set display label to verb to test + [self setUILabelTitle:self.testedVerbLabel withText:self.currentVerb.verb.verb inColour:[UIColor blackColor] andSize:30]; + + [self setUILabelTitle:self.verbMeaningLable withText:self.currentVerb.verb.meaning inColour:[UIColor blackColor] andSize:12]; + + [self setUILabelTitle:self.verbPersonLabel withText:[[[self.lesson getConjugationEngine] persons] objectForKey:self.currentVerb.person] inColour:[UIColor blackColor] andSize:16]; + + + // Get the shuffles answers; + answers = [self.lesson.getConjugationEngine getTestConjugationsForVerb:self.currentVerb.verb.verb inPerson:self.currentVerb.person andTense:[self.lesson getTenseAsTense]]; + + + [self setAnswerButton:self.answer1Button withAnswer:[self popLastFromArray:answers] andCorrect:correctAnswer]; + + [self setAnswerButton:self.answer2Button withAnswer:[self popLastFromArray:answers] andCorrect:correctAnswer]; + + [self setAnswerButton:self.answer3Button withAnswer:[self popLastFromArray:answers] andCorrect:correctAnswer]; + + [self setAnswerButton:self.answer4Button withAnswer:[self popLastFromArray:answers] andCorrect:correctAnswer]; + + } else { + NSLog(@"Que horror, no lesson!"); + } + +} + + +- (void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + + self.nextButton.titleLabel.text = NSLocalizedString(@"Next", @"Next button in the testing screen to continue to the next verb"); + + [self.nextButton setTitle:NSLocalizedString(@"Next", @"Next button in the testing screen to continue to the next verb") forState:UIControlStateNormal]; + + self.title = [self.lesson getTenseName]; + + if ( [self.testSet count] > 0) { + [self nextVerb]; + } +} + + + @end diff --git a/Espagram/EspagramWordsInLessonViewController.h b/Espagram/EspagramWordsInLessonViewController.h new file mode 100644 index 0000000..efd245c --- /dev/null +++ b/Espagram/EspagramWordsInLessonViewController.h @@ -0,0 +1,19 @@ +// +// EspagramWordsInLessonViewController.h +// Espagram +// +// Created by Abel Fokkinga on 11/14/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import +#import "CoreDataTableViewController.h" +#import "EspagramAddWordToLessonViewController.h" +#import "EspagramConjugationTableViewController.h" +#import "Lesson.h" + +@interface EspagramWordsInLessonViewController : CoreDataTableViewController ; + +@property (nonatomic, strong) Lesson * lesson; + +@end diff --git a/Espagram/EspagramWordsInLessonViewController.m b/Espagram/EspagramWordsInLessonViewController.m new file mode 100644 index 0000000..791a489 --- /dev/null +++ b/Espagram/EspagramWordsInLessonViewController.m @@ -0,0 +1,140 @@ +// +// EspagramWordsInLessonViewController.m +// Espagram +// +// Created by Abel Fokkinga on 11/14/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import "EspagramWordsInLessonViewController.h" +#import "Conjugator.h" +#import "Verb+Create.h" + +@interface EspagramWordsInLessonViewController () +@end + +@implementation EspagramWordsInLessonViewController + +@synthesize lesson = _lesson; + + +- (IBAction)AddButtonPressed:(id)sender { + [self performSegueWithIdentifier:@"Add A Word To Lesson" sender:self]; +} + +- (void) addWord:(NSString *)word withMeaning:(NSString *)meaning{ + if ( word ) { + [Verb addVerb:word andMeaning:meaning toLesson:self.lesson]; + } + [[self parentViewController] dismissViewControllerAnimated:TRUE completion:^{ + NSLog(@"Word added"); + }]; +} + +- (void) cancelAddingWord{ + [[self parentViewController] dismissViewControllerAnimated:TRUE completion:^{ NSLog(@"Adding a word cancelled"); + }]; +} + +- (void)setupFetchedResultsController // attaches an NSFetchRequest to this UITableViewController +{ + NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Verb"]; + request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"verb" + ascending:YES + selector:@selector(localizedCompare:)]]; + + request.predicate = [NSCompoundPredicate andPredicateWithSubpredicates:[NSArray arrayWithObjects:[NSPredicate predicateWithFormat:@"lesson.title = %@", self.lesson.title], [NSPredicate predicateWithFormat:@"lesson.tense = %@", self.lesson.tense], [NSPredicate predicateWithFormat:@"lesson.conjugator = %@", self.lesson.conjugator],nil]]; + + + self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request + managedObjectContext:self.lesson.managedObjectContext + sectionNameKeyPath:nil + cacheName:nil]; +} + + +- (void)setLesson:(Lesson *)lesson +{ + _lesson = lesson; + self.title = lesson.title; + [self setupFetchedResultsController]; +} + + + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *CellIdentifier = @"Word Cell"; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; + + // Configure the cell... + Verb * verb = [self.fetchedResultsController objectAtIndexPath:indexPath]; + cell.textLabel.text = verb.verb; + cell.detailTextLabel.text = verb.meaning; + + return cell; +} + + +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + if ( [segue.identifier isEqualToString:@"Add A Word To Lesson"]) { + [segue.destinationViewController setDataSource:self]; + } + + if ( [segue.identifier isEqualToString:@"Conjugate"]) { + Verb * selectedVerb = [self.fetchedResultsController objectAtIndexPath:sender]; + [segue.destinationViewController setVerb:selectedVerb]; + } +} + + +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath +{ + // Return NO if you do not want the specified item to be editable. + return YES; +} + + + +// Override to support editing the table view. +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + //[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + Verb * selectedVerb = [self.fetchedResultsController objectAtIndexPath:indexPath]; + [self.lesson removeVerbsObject:selectedVerb]; + } + // else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + // } +} + + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath +{ +} +*/ + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath +{ + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + +#pragma mark - Table view delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + [self performSegueWithIdentifier:@"Conjugate" sender:indexPath]; +} + +@end diff --git a/Espagram/GrammarTestViewController.h b/Espagram/GrammarTestViewController.h deleted file mode 100644 index 1319009..0000000 --- a/Espagram/GrammarTestViewController.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// GrammarTestViewController.h -// Espagram -// -// Created by Abel Fokkinga on 10/15/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import -#import "Conjugator.h" -#import "EspagramConjugationTableViewController.h" - -@class GrammarTestViewController; - -@interface GrammarTestViewController : UIViewController - -@property (weak, nonatomic) UITextField *verbInput; - -@property (weak, nonatomic) IBOutlet UIView *conjugatedVerbTable; - -@end diff --git a/Espagram/GrammarTestViewController.m b/Espagram/GrammarTestViewController.m deleted file mode 100644 index d1441a9..0000000 --- a/Espagram/GrammarTestViewController.m +++ /dev/null @@ -1,69 +0,0 @@ -// -// GrammarTestViewController.m -// Espagram -// -// Created by Abel Fokkinga on 10/15/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import "GrammarTestViewController.h" - - -@implementation GrammarTestViewController - -@synthesize conjugator = _conjugator; -@synthesize verbInput = _verbInput; -@synthesize tense = _tense; -@synthesize verb = _verb; -@synthesize conjugatedVerbTable = _conjugatedVerbTable; - - -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil -{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - // Custom initialization - } - return self; -} - -- (IBAction)verbEntered:(id)sender { - self.verb = self.verbInput.text; - [self.view resignFirstResponder]; -} - -- (void) verb:(NSString *) verb { - _verb = verb; - if ( ! [_verb isEqualToString:self.verbInput.text]) - self.verbInput.text = _verb; -} - -- (void) setup{ - NSLog([self.conjugator description]); - NSLog(@"Persons %d", [[[self conjugator] persons] count]); -} - -- (void) awakeFromNib -{ - [self setup]; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - // Do any additional setup after loading the view. - - [self setup]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} -; -- (void)viewDidUnload { - [self setVerbInput:nil]; - [super viewDidUnload]; -} -@end diff --git a/Espagram/Lesson+Conjugator.h b/Espagram/Lesson+Conjugator.h new file mode 100644 index 0000000..701c163 --- /dev/null +++ b/Espagram/Lesson+Conjugator.h @@ -0,0 +1,21 @@ +// +// Lesson+Conjugator.h +// Espagram +// +// Created by Abel Fokkinga on 11/14/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import "Lesson.h" +#import "Conjugator.h" +#import "tense.h" + +@interface Lesson (Conjugator) + +- (id )getConjugationEngine; + +- (Tense *) getTenseAsTense; + +- (NSString *) getTenseName; + +@end diff --git a/Espagram/Lesson+Conjugator.m b/Espagram/Lesson+Conjugator.m new file mode 100644 index 0000000..f3ff008 --- /dev/null +++ b/Espagram/Lesson+Conjugator.m @@ -0,0 +1,37 @@ +// +// Lesson+Conjugator.m +// Espagram +// +// Created by Abel Fokkinga on 11/14/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import "Lesson+Conjugator.h" +#import "SpanishConjugator.h" + +@implementation Lesson (Conjugator) + + +- (id ) getConjugationEngine +{ + if ( [self.conjugator isEqualToString:@"Spanish"] ) + return [[SpanishConjugator alloc] init]; + else + return nil; +} + +- (Tense *) getTenseAsTense +{ + Tense * tense = [[Tense alloc] init]; + tense.tense = self.tense; + return tense; +} + +- (NSString *) getTenseName +{ + Tense * tense = [[Tense alloc] init]; + tense.tense = self.tense; + return [tense getTenseInLanguage:self.conjugator]; +} + +@end diff --git a/Espagram/Lesson+Create.h b/Espagram/Lesson+Create.h new file mode 100644 index 0000000..6726467 --- /dev/null +++ b/Espagram/Lesson+Create.h @@ -0,0 +1,18 @@ +// +// Lesson+Create.h +// Palabel +// +// Created by Abel Fokkinga on 1/29/12. +// Copyright (c) 2012 T-consult International vof. All rights reserved. +// + +#import "Lesson.h" +#import "Tense.h" +#import "Conjugator.h" + +@interface Lesson (Create) + ++ (void) addLessonWithTitle:(NSString *) title andSubTitle:(NSString *)subTitle +inTense:(Tense *)tense conjugatedBy:(id ) conjugator inManagedObjectContext:(NSManagedObjectContext *) context; + +@end diff --git a/Espagram/Lesson+Create.m b/Espagram/Lesson+Create.m new file mode 100644 index 0000000..85fa446 --- /dev/null +++ b/Espagram/Lesson+Create.m @@ -0,0 +1,50 @@ +// +// Lesson+Create.m +// Palabel +// +// Created by Abel Fokkinga on 1/29/12. +// Copyright (c) 2012 T-consult International vof. All rights reserved. +// + +#import "Lesson+Create.h" + +@implementation Lesson (Create) + ++ (void) addLessonWithTitle:(NSString *) title andSubTitle:(NSString *)subTitle + inTense:(Tense *)tense conjugatedBy:(id ) conjugator inManagedObjectContext:(NSManagedObjectContext *) context + +{ + Lesson *lesson = nil; + // Check if a lesson with this name already exists for this tense + + NSLog(@"Adding Lesson %@ for tense %@ in %@ at context %@", title, tense.tense, [conjugator description], context); + + NSFetchRequest *request = [[NSFetchRequest alloc] initWithEntityName:@"Lesson"]; + + // Where clause + request.predicate = [NSCompoundPredicate andPredicateWithSubpredicates:[NSArray arrayWithObjects:[NSPredicate predicateWithFormat:@"title = %@", title],[NSPredicate predicateWithFormat:@"tense = %@", tense.tense], [NSPredicate predicateWithFormat:@"conjugator = %@", [conjugator description]],nil]]; + + // Order by + //request.sortDescriptors = [NSSortDescriptor sortDescriptorWithKey:@"dateAdded" ascending:YES]; + + + NSError *error = nil; + NSArray *lessons = [context executeFetchRequest:request error:&error]; + + if ( error || [lessons count] > 0) { + NSLog(@"Could not add lesson: %@", error.description); + } else { + NSLog(@"Inserting new lesson in context %@", context); + lesson = [NSEntityDescription insertNewObjectForEntityForName:@"Lesson" inManagedObjectContext:context]; + lesson.title = title; + lesson.subTitle = subTitle; + lesson.tense = tense.tense; + lesson.conjugator = [conjugator description]; + lesson.dateAdded = [[NSDate alloc] initWithTimeIntervalSinceNow:0]; + + NSLog(@"Saving context"); + [context save:&error]; + } +} + +@end diff --git a/Espagram/Lesson+Test.h b/Espagram/Lesson+Test.h new file mode 100644 index 0000000..d67af52 --- /dev/null +++ b/Espagram/Lesson+Test.h @@ -0,0 +1,18 @@ +// +// Lesson+Test.h +// Espagram +// +// Created by Abel Fokkinga on 11/15/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import "Lesson.h" +#import "TestableVerb.h" + + +@interface Lesson (Test) + +// Returns TestableVerbs +- (NSMutableArray *) testableVerbs; + +@end diff --git a/Espagram/Lesson+Test.m b/Espagram/Lesson+Test.m new file mode 100644 index 0000000..64ef525 --- /dev/null +++ b/Espagram/Lesson+Test.m @@ -0,0 +1,33 @@ +// +// Lesson+Test.m +// Espagram +// +// Created by Abel Fokkinga on 11/15/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import "Lesson+Conjugator.h" +#import "Lesson+Test.h" +#import "Conjugator.h" +#import "NSMutableArray_Shuffling.h" + +@implementation Lesson (Test) + +- (NSArray *) testableVerbs; +{ + NSMutableArray *testableVerbs = [[NSMutableArray alloc] init]; + for ( NSString *person in [[self getConjugationEngine] personsKeys]) { + for ( Verb *verb in self.verbs.allObjects) { + TestableVerb * testableVerb = [[TestableVerb alloc] init]; + testableVerb.verb = verb; + testableVerb.person = person; + [testableVerbs addObject:testableVerb]; + } + } + // shuffle list + [testableVerbs shuffle]; + + return testableVerbs; +} + +@end diff --git a/Espagram/Lesson.h b/Espagram/Lesson.h new file mode 100644 index 0000000..21bc105 --- /dev/null +++ b/Espagram/Lesson.h @@ -0,0 +1,31 @@ +// +// Lesson.h +// Espagram +// +// Created by Abel Fokkinga on 11/13/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import +#import + +@class Verb; + +@interface Lesson : NSManagedObject + +@property (nonatomic, retain) NSDate * dateAdded; +@property (nonatomic, retain) NSString * subTitle; +@property (nonatomic, retain) NSString * tense; +@property (nonatomic, retain) NSString * title; +@property (nonatomic, retain) NSString * conjugator; +@property (nonatomic, retain) NSSet *verbs; +@end + +@interface Lesson (CoreDataGeneratedAccessors) + +- (void)addVerbsObject:(Verb *)value; +- (void)removeVerbsObject:(Verb *)value; +- (void)addVerbs:(NSSet *)values; +- (void)removeVerbs:(NSSet *)values; + +@end diff --git a/Espagram/Lesson.m b/Espagram/Lesson.m new file mode 100644 index 0000000..1257698 --- /dev/null +++ b/Espagram/Lesson.m @@ -0,0 +1,22 @@ +// +// Lesson.m +// Espagram +// +// Created by Abel Fokkinga on 11/13/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import "Lesson.h" +#import "Verb.h" + + +@implementation Lesson + +@dynamic dateAdded; +@dynamic subTitle; +@dynamic tense; +@dynamic title; +@dynamic conjugator; +@dynamic verbs; + +@end diff --git a/Espagram/Persons.h b/Espagram/Persons.h deleted file mode 100644 index d2bd931..0000000 --- a/Espagram/Persons.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// Persons.h -// Espagram -// -// Created by Abel Fokkinga on 8/29/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import -#import - - -@interface Persons : NSManagedObject - -@property (nonatomic, retain) NSString * language; -@property (nonatomic, retain) NSString * person; -@property (nonatomic, retain) NSString * translation; - -@end diff --git a/Espagram/Persons.m b/Espagram/Persons.m deleted file mode 100644 index 154e029..0000000 --- a/Espagram/Persons.m +++ /dev/null @@ -1,18 +0,0 @@ -// -// Persons.m -// Espagram -// -// Created by Abel Fokkinga on 8/29/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import "Persons.h" - - -@implementation Persons - -@dynamic language; -@dynamic person; -@dynamic translation; - -@end diff --git a/Espagram/SpanishConjugator.h b/Espagram/SpanishConjugator.h index cc828d7..9844eeb 100644 --- a/Espagram/SpanishConjugator.h +++ b/Espagram/SpanishConjugator.h @@ -12,5 +12,4 @@ @interface SpanishConjugator : NSObject - @end diff --git a/Espagram/SpanishConjugator.m b/Espagram/SpanishConjugator.m index 8cc89bc..5ef171b 100644 --- a/Espagram/SpanishConjugator.m +++ b/Espagram/SpanishConjugator.m @@ -7,6 +7,7 @@ // #import "SpanishConjugator.h" +#import "NSMutableArray_Shuffling.h" @interface SpanishConjugator() @@ -15,15 +16,19 @@ *simplePresentEtoIstemChangersArray; @property (nonatomic,strong) NSDictionary *persons; +@property (nonatomic,strong) NSDictionary *reflexivePersons; @end @implementation SpanishConjugator +#pragma mark - variables + @synthesize simplePresentEtoIEstemChangersArray = _simplePresentEtoIEstemChangersArray; @synthesize simplePresentOtoUEstemChangersArray = _simplePresentOtoUEstemChangersArray; @synthesize simplePresentEtoIstemChangersArray = _simplePresentEtoIstemChangersArray; @synthesize persons = _persons; +@synthesize reflexivePersons = _reflexivePersons; - (NSString *) description @@ -44,49 +49,143 @@ return [_persons copy]; } +- (NSDictionary *) reflexivePersons { + if (_reflexivePersons == nil) { + _reflexivePersons = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] + initWithObjects:@"me",@"te",@"se",@"nos", @"os", @"se", nil] forKeys:[[NSArray alloc] initWithArray:self.personsKeys]]; + } + return [_reflexivePersons copy]; +} + + - (NSArray *) simplePresentEtoIEstemChangersArray{ if (_simplePresentEtoIEstemChangersArray == nil) - _simplePresentEtoIEstemChangersArray = [[NSArray alloc] initWithObjects:@"acertar", @"encender",@"advertir",@"entender",@"cerrar",@"fregar",@"comenzar",@"hervir",@"confesar",@"mentir",@"consentir",@"negar",@"convertir",@"pensar",@"defender",@"perder",@"empezar",@"preferir",@"querer",@"merendar",nil]; + _simplePresentEtoIEstemChangersArray = [[NSArray alloc] initWithObjects: + @"acertar", + @"advertir", + @"adtrevesar", + @"calentar", + @"cerrar", + @"comenzar", + @"confesar", + @"consentir", + @"convertir", + @"defender", + @"despertar", + @"divertir", + @"empezar", + @"encender", + @"entender", + @"gobernar", + @"fregar", + @"herir", + @"hervir", + @"mentir", + @"merendar", + @"negar", + @"pensar", + @"perder", + @"preferir", + @"querer", + @"sentir", + @"tropezar", + nil]; return _simplePresentEtoIEstemChangersArray; } - (NSArray *) simplePresentOtoUEstemChangersArray{ if (_simplePresentOtoUEstemChangersArray == nil) - _simplePresentOtoUEstemChangersArray = [[NSArray alloc] initWithObjects:@"almorzar",@"morir",@"aprobar",@"mostrar",@"colgar",@"mover",@"contar",@"probar",@"costar",@"recordar",@"devolver",@"resolver",@"volver",@"rogar",@"dormir",@"sonar",@"encontrar",@"soñar",@"envolver",@"tostar",@"morder",@"volar",@"poder",nil]; + _simplePresentOtoUEstemChangersArray = [[NSArray alloc] initWithObjects: + @"acordar", + @"acostar", + @"almorzar", + @"apostar", + @"aprobar", + @"colgar", + @"contar", + @"costar", + @"devolver", + @"dormir", + @"encontrar", + @"envolver", + @"llover", + @"morder", + @"morir", + @"mostrar", + @"mover", + @"oler", + @"poder", + @"probar", + @"recordar", + @"resolver", + @"rogar", + @"sonar", + @"soñar", + @"tostar", + @"volar", + @"volver", + @"oler" + ,nil]; return _simplePresentOtoUEstemChangersArray; } - (NSArray *) simplePresentEtoIstemChangersArray{ if (_simplePresentEtoIstemChangersArray == nil) - _simplePresentEtoIstemChangersArray = [[NSArray alloc] initWithObjects:@"impedir",@"colegir",@"competir",@"medir",@"conseguir",@"pedir",@"corregir",@"perseguir",@"reír",@"despedir",@"repetir", @"seguir",@"freír",@"servir",@"gemir",@"sonreír",nil]; // not including elegir here as it also has an g to j change in first person singular + _simplePresentEtoIstemChangersArray = [[NSArray alloc] initWithObjects: + @"colegir", + @"competir", + @"conseguir", + @"corregir", + @"derretir", + @"despedir", + @"elegir", + @"freír", + @"gemir", + @"impedir", + @"medir", + @"pedir", + @"perseguir", + @"repetir", + @"reír", + @"seguir", + @"servir", + @"sonreír", + @"repetir", + @"vestir" + ,nil]; // not including elegir here as it also has an g to j change in first person singular return _simplePresentEtoIstemChangersArray; } + - (NSString *) getExit:(NSString *) verb { NSLog(@"getExit start"); - - return [verb substringFromIndex:[verb length] - 2]; - + if ( verb.length > 2 ) + return [verb substringFromIndex:[verb length] - 2]; + else + return @""; } - (NSString *) getStem:(NSString *) verb { NSLog(@"getStem start"); - if ( [[self getExit:verb] isEqualToString:@"ír"] ) - return [[verb substringToIndex:[verb length] -2] stringByAppendingString:@"i"]; + // if ( [[self getExit:verb] isEqualToString:@"ír"] ) + // return [[verb substringToIndex:[verb length] -2] stringByAppendingString:@"i"]; NSLog(@"getStem end"); return [verb substringToIndex:[verb length] -2]; } +# pragma mark - Simple Present + - (NSString *) getSimplePresentStemVerb:(NSString *) verb inPerson:(NSString *) person { NSString * verbStem = [self getStem:verb]; + NSString * verbExit = [self getExit:verb]; NSLog(@"getSimplePresentStemVerb start.irregular"); @@ -100,11 +199,6 @@ if ( [verb isEqualToString:@"oír"] ) return @"oig"; - - // conducir, conocer etc. - if ( [[verb substringFromIndex:[verb length] - 3] isEqualToString:@"cer"] || - [[verb substringFromIndex:[verb length] - 3] isEqualToString:@"cir"] ) - return [[verbStem substringToIndex:[verbStem length] - 1] stringByAppendingString:@"zc"]; if ( [verb isEqualToString:@"oír"] ) return @"oí"; @@ -125,6 +219,11 @@ if ( [verb rangeOfString:@"venir"].location != NSNotFound) return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"ven"] withString:@"veng"]; + // conducir, conocer etc. + if ( verb.length > 3 && ([[verb substringFromIndex:[verb length] - 3] isEqualToString:@"cer"] || + [[verb substringFromIndex:[verb length] - 3] isEqualToString:@"cir"]) ) + return [[verbStem substringToIndex:[verbStem length] - 1] stringByAppendingString:@"zc"]; + // other if ( [verb isEqualToString:@"ver"] ) return @"ve"; @@ -132,11 +231,11 @@ if ( [verb isEqualToString:@"elegir"] ) return @"elij"; // g -> j - if ( [[verb substringFromIndex:[verb length] - 3] isEqualToString:@"gir"] ) + if ( verb.length > 3 && [[verb substringFromIndex:[verb length] - 3] isEqualToString:@"gir"] ) return [[verb substringToIndex:[verb length] - 3] stringByAppendingString:@"j"]; // gu -> g - if ( [[verb substringFromIndex:[verb length] - 4] isEqualToString:@"guir"] ) + if ( verb.length > 4 && [[verb substringFromIndex:[verb length] - 4] isEqualToString:@"guir"] ) return [[verb substringToIndex:[verb length] - 4] stringByAppendingString:@"g"]; @@ -185,22 +284,25 @@ ) { if ( [[self simplePresentEtoIEstemChangersArray] containsObject:verb] ) { // Verb changes stem from e to ie - return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e"] withString:@"ie"]; + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"]; } if ( [[self simplePresentOtoUEstemChangersArray] containsObject:verb] ) { - // Verb changes stem from e to ie - return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o"] withString:@"ue"]; + // Verb changes stem from o to ue + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"]; } if ( [[self simplePresentEtoIstemChangersArray] containsObject:verb] ) { - // Verb changes stem from e to ie - return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e"] withString:@"i"]; + // Verb changes stem from e to i + if ( [[verbExit substringToIndex:verbExit.length-1] isEqualToString:@"í"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"í"]; + else + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"]; } // u -> ue if ( [verb isEqualToString:@"jugar"]) return @"jueg"; // huir, construir - if ( [[verb substringFromIndex:[verb length] - 3] isEqualToString:@"uir"] && + if ( verb.length > 3 && [[verb substringFromIndex:[verb length] - 3] isEqualToString:@"uir"] && ![[verb substringFromIndex:[verb length] - 3] isEqualToString:@"guir"]) return [[verb substringToIndex:[verb length] - 3] stringByAppendingString:@"uy"]; } @@ -263,6 +365,7 @@ if ( [@"ar" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"amos"]; if ( [@"er" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"emos"]; + if ( [@"ír" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"ímos"]; if ( [@"ir" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"imos"]; } if ( [person isEqualToString:@"SECOND_PERSON_PLURAL"]) { @@ -273,6 +376,7 @@ if ( [@"ar" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"áis"]; if ( [@"er" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"éis"]; + if ( [@"ír" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"ís"]; if ( [@"ir" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"ís"]; } if ( [person isEqualToString:@"THIRD_PERSON_PLURAL"]) { @@ -290,6 +394,437 @@ } +# pragma mark - Present subjuntivo +- (NSString *) conjugatePresentSubjunctiveVerb:(NSString *) verb inPerson:(NSString *) person { + + NSString * verbStem = [self getStem:verb]; + NSString * verbExit = [self getExit:verb]; + NSString * simplePresentYo = [self conjugateSimplePresentVerb:verb inPerson:@"FIRST_PERSON_SINGULAR"]; + NSString * simplePresentYoStem = [simplePresentYo substringToIndex:simplePresentYo.length -1]; + + + if ( [person isEqualToString:@"FIRST_PERSON_SINGULAR"] || + [person isEqualToString:@"THIRD_PERSON_SINGULAR"] ) { + + // 1. If the first person singular does not end in an -o, the verb is irregular in the present subjunctive + if ( [verb isEqualToString:@"ser"]) + return @"sea"; + if ( [verb isEqualToString:@"estar"]) + return @"esté"; + if ( [verb isEqualToString:@"ir"]) + return @"vaya"; + if ( [verb isEqualToString:@"dar"]) + return @"dé"; + if ( [verb isEqualToString:@"saber"]) + return @"sepa"; + if ( [verb isEqualToString:@"haber"]) + return @"haya"; + + // 2. If the stem of the yo form is exactly the same as the stem of the infinitive, the verb is regular + + // Orthographic changes + if ( simplePresentYoStem.length > 2 && + [[simplePresentYoStem substringFromIndex:simplePresentYoStem.length - 2] isEqualToString:@"go"] ) + return [[simplePresentYoStem substringToIndex:simplePresentYoStem.length - 1] stringByAppendingString:@"a"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"car"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"que"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"gar"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"gue"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"zar"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"ce"]; + if ( verb.length > 4 && + [[verb substringFromIndex:verb.length - 4] isEqualToString:@"guir"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"gu" options:NSBackwardsSearch] withString:@"ga"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"gir"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"g" options:NSBackwardsSearch] withString:@"ja"]; + + + if ( [verbStem isEqualToString:simplePresentYoStem]) { + if ( [verbExit isEqualToString:@"ar"] ) + return [verbStem stringByAppendingString:@"e"]; + else + return [verbStem stringByAppendingString:@"a"]; + } + + // 3. If the stem of the yo form shows a stem change when compared to the stem of the infinitive, + // and it's an -ar or -er verb,the stem will undergo the same changes as the present indicative + if ( ![verbExit isEqualToString:@"ir"] ) { + + if ( [[self simplePresentEtoIEstemChangersArray] containsObject:verb] || + [[self simplePresentOtoUEstemChangersArray] containsObject:verb] || + [[self simplePresentEtoIstemChangersArray] containsObject:verb] || + [verb isEqualToString:@"jugar"] ) { + + if ( [verb isEqualToString:@"jugar"] ) return @"juegue"; + + if ( [verbExit isEqualToString:@"ar"] ) + return [simplePresentYoStem stringByAppendingString:@"e"]; + else + return [simplePresentYoStem stringByAppendingString:@"a"]; + } + } + + // 4. if the stem of the yo form when compared to infinitie shows it's an -ir stem changing verb, all + // forms of the present subjunctive will have stem changes + if ( [verbExit isEqualToString:@"ir"] ) { + + if ( [[self simplePresentEtoIEstemChangersArray] containsObject:verb] || + [[self simplePresentOtoUEstemChangersArray] containsObject:verb] || + [[self simplePresentEtoIstemChangersArray] containsObject:verb] ) { + + return [simplePresentYoStem stringByAppendingString:@"a"]; + } + } + + // 5. Changing stem in yo form and not a stem changing verb,: use this stem for all forms of + // present subjuntive + + if ( [verbExit isEqualToString:@"ar"] ) + return [simplePresentYoStem stringByAppendingString:@"e"]; + else + return [simplePresentYoStem stringByAppendingString:@"a"]; + + } else if ( [person isEqualToString:@"SECOND_PERSON_SINGULAR"]) { + + // 1. If the first person singular does not end in an -o, the verb is irregular in the present subjunctive + if ( [verb isEqualToString:@"ser"]) + return @"seas"; + if ( [verb isEqualToString:@"estar"]) + return @"estés"; + if ( [verb isEqualToString:@"ir"]) + return @"vayas"; + if ( [verb isEqualToString:@"dar"]) + return @"des"; + if ( [verb isEqualToString:@"saber"]) + return @"sepas"; + if ( [verb isEqualToString:@"haber"]) + return @"hayas"; + + // 2. If the stem of the yo form is exactly the same as the stem of the infinitive, the verb is regular + + // Orthographic changes + if ( simplePresentYoStem.length > 2 && + [[simplePresentYoStem substringFromIndex:simplePresentYoStem.length - 2] isEqualToString:@"go"] ) + return [[simplePresentYoStem substringToIndex:simplePresentYoStem.length - 1] stringByAppendingString:@"as"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"car"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"ques"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"gar"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"gues"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"zar"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"ces"]; + if ( verb.length > 4 && + [[verb substringFromIndex:verb.length - 4] isEqualToString:@"guir"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"gu" options:NSBackwardsSearch] withString:@"gas"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"gir"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"g" options:NSBackwardsSearch] withString:@"jas"]; + + + if ( [verbStem isEqualToString:simplePresentYoStem]) { + if ( [verbExit isEqualToString:@"ar"] ) + return [verbStem stringByAppendingString:@"es"]; + else + return [verbStem stringByAppendingString:@"as"]; + } + + // 3. If the stem of the yo form shows a stem change when compared to the stem of the infinitive, + // and it's an -ar or -er verb,the stem will undergo the same changes as the present indicative + if ( ![verbExit isEqualToString:@"ir"] ) { + + if ( [[self simplePresentEtoIEstemChangersArray] containsObject:verb] || + [[self simplePresentOtoUEstemChangersArray] containsObject:verb] || + [[self simplePresentEtoIstemChangersArray] containsObject:verb] || + [verb isEqualToString:@"jugar"] ) { + + if ( [verb isEqualToString:@"jugar"] ) return @"juegues"; + + if ( [verbExit isEqualToString:@"ar"] ) + return [simplePresentYoStem stringByAppendingString:@"es"]; + else + return [simplePresentYoStem stringByAppendingString:@"as"]; + } + } + + // 4. if the stem of the yo form when compared to infinitie shows it's an -ir stem changing verb, all + // forms of the present subjunctive will have stem changes and special changes in nosotros and vosotros + if ( [verbExit isEqualToString:@"ir"] ) { + + if ( [[self simplePresentEtoIEstemChangersArray] containsObject:verb] || + [[self simplePresentOtoUEstemChangersArray] containsObject:verb] || + [[self simplePresentEtoIstemChangersArray] containsObject:verb] ) { + + return [simplePresentYoStem stringByAppendingString:@"as"]; + } + } + + // 5. Changing stem in yo form and not a stem changing verb,: use this stem for all forms of + // present subjuntive + if ( [verbExit isEqualToString:@"ar"] ) + return [simplePresentYoStem stringByAppendingString:@"es"]; + else + return [simplePresentYoStem stringByAppendingString:@"as"]; + + } else if ( [person isEqualToString:@"FIRST_PERSON_PLURAL"]) { + + // 1. If the first person singular does not end in an -o, the verb is irregular in the present subjunctive + if ( [verb isEqualToString:@"ser"]) + return @"seamos"; + if ( [verb isEqualToString:@"estar"]) + return @"estemos"; + if ( [verb isEqualToString:@"ir"]) + return @"vayamos"; + if ( [verb isEqualToString:@"dar"]) + return @"demos"; + if ( [verb isEqualToString:@"saber"]) + return @"sepamos"; + if ( [verb isEqualToString:@"haber"]) + return @"hayamos"; + + // 2. If the stem of the yo form is exactly the same as the stem of the infinitive, the verb is regular + // Orthographic changes + if ( simplePresentYoStem.length > 2 && + [[simplePresentYoStem substringFromIndex:simplePresentYoStem.length - 2] isEqualToString:@"go"] ) + return [[simplePresentYoStem substringToIndex:simplePresentYoStem.length - 1] stringByAppendingString:@"gamos"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"car"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"quemos"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"gar"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"guemos"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"zar"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"cemos"]; + if ( verb.length > 4 && + [[verb substringFromIndex:verb.length - 4] isEqualToString:@"guir"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"gu" options:NSBackwardsSearch] withString:@"gamos"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"gir"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"g" options:NSBackwardsSearch] withString:@"jamos"]; + + + + if ( [verbStem isEqualToString:simplePresentYoStem]) { + if ( [verbExit isEqualToString:@"ar"] ) + return [verbStem stringByAppendingString:@"emos"]; + else + return [verbStem stringByAppendingString:@"amos"]; + } + + // 3. If the stem of the yo form shows a stem change when compared to the stem of the infinitive, + // and it's an -ar or -er verb,the stem will undergo the same changes as the present indicative + if ( ![verbExit isEqualToString:@"ir"] ) { + + if ( [[self simplePresentEtoIEstemChangersArray] containsObject:verb] || + [[self simplePresentOtoUEstemChangersArray] containsObject:verb] || + [[self simplePresentEtoIstemChangersArray] containsObject:verb] || + [verb isEqualToString:@"jugar"] ) { + + if ( [verb isEqualToString:@"jugar"] ) return @"jueguemos"; + + if ( [verbExit isEqualToString:@"ar"] ) + return [verbStem stringByAppendingString:@"emos"]; + else + return [verbStem stringByAppendingString:@"amos"]; + } + } + + // 4. if the stem of the yo form when compared to infinitie shows it's an -ir stem changing verb, all + // forms of the present subjunctive will have stem changes and special changes in nosotros and vosotros + if ( [verbExit isEqualToString:@"ir"] ) { + + if ( [[self simplePresentEtoIEstemChangersArray] containsObject:verb] ) + return [[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"amos"]; + + if ( [[self simplePresentOtoUEstemChangersArray] containsObject:verb] ) + return [[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"u"] stringByAppendingString:@"amos"]; + } + + // 5. Changing stem in yo form and not a stem changing verb,: use this stem for all forms of + // present subjuntive + if ( [verbExit isEqualToString:@"ar"] ) + return [simplePresentYoStem stringByAppendingString:@"emos"]; + else + return [simplePresentYoStem stringByAppendingString:@"amos"]; + + } else if ( [person isEqualToString:@"SECOND_PERSON_PLURAL"]) { + + // 1. If the first person singular does not end in an -o, the verb is irregular in the present subjunctive + if ( [verb isEqualToString:@"ser"]) + return @"seáis"; + if ( [verb isEqualToString:@"estar"]) + return @"estéis"; + if ( [verb isEqualToString:@"ir"]) + return @"vayáis"; + if ( [verb isEqualToString:@"dar"]) + return @"deis"; + if ( [verb isEqualToString:@"saber"]) + return @"sepáis"; + if ( [verb isEqualToString:@"haber"]) + return @"hayáis"; + + // 2. If the stem of the yo form is exactly the same as the stem of the infinitive, the verb is regular + // Orthographic changes + if ( simplePresentYoStem.length > 2 && + [[simplePresentYoStem substringFromIndex:simplePresentYoStem.length - 2] isEqualToString:@"go"] ) + return [[simplePresentYoStem substringToIndex:simplePresentYoStem.length - 1] stringByAppendingString:@"áis"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"car"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"quéis"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"gar"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"guéis"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"zar"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"céis"]; + if ( verb.length > 4 && + [[verb substringFromIndex:verb.length - 4] isEqualToString:@"guir"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"gu" options:NSBackwardsSearch] withString:@"gáis"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"gir"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"g" options:NSBackwardsSearch] withString:@"jáis"]; + + + + if ( [verbStem isEqualToString:simplePresentYoStem]) { + if ( [verbExit isEqualToString:@"ar"] ) + return [verbStem stringByAppendingString:@"éis"]; + else + return [verbStem stringByAppendingString:@"áis"]; + } + + // 3. If the stem of the yo form shows a stem change when compared to the stem of the infinitive, + // and it's an -ar or -er verb,the stem will undergo the same changes as the present indicative + if ( ![verbExit isEqualToString:@"ir"] ) { + + if ( [[self simplePresentEtoIEstemChangersArray] containsObject:verb] || + [[self simplePresentOtoUEstemChangersArray] containsObject:verb] || + // NOT [[self simplePresentEtoIstemChangersArray] containsObject:verb] || + [verb isEqualToString:@"jugar"] ) { + + if ( [verb isEqualToString:@"jugar"] ) return @"jueguéis"; + + if ( [verbExit isEqualToString:@"ar"] ) + return [verbStem stringByAppendingString:@"éis"]; + else + return [verbStem stringByAppendingString:@"áis"]; + } + } + + // 4. if the stem of the yo form when compared to infinitie shows it's an -ir stem changing verb, all + // forms of the present subjunctive will have stem changes and special changes in nosotros and vosotros + if ( [verbExit isEqualToString:@"ir"] ) { + + if ( [[self simplePresentEtoIEstemChangersArray] containsObject:verb] ) + return [[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"áis"]; + + if ( [[self simplePresentOtoUEstemChangersArray] containsObject:verb] ) + return [[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"u"] stringByAppendingString:@"áis"]; + } + + // 5. Changing stem in yo form and not a stem changing verb,: use this stem for all forms of + // present subjuntive + if ( [verbExit isEqualToString:@"ar"] ) + return [simplePresentYoStem stringByAppendingString:@"éis"]; + else + return [simplePresentYoStem stringByAppendingString:@"áis"]; + + } else if ( [person isEqualToString:@"THIRD_PERSON_PLURAL"]) { + + // 1. If the first person singular does not end in an -o, the verb is irregular in the present subjunctive + if ( [verb isEqualToString:@"ser"]) + return @"sean"; + if ( [verb isEqualToString:@"estar"]) + return @"estén"; + if ( [verb isEqualToString:@"ir"]) + return @"vayan"; + if ( [verb isEqualToString:@"dar"]) + return @"den"; + if ( [verb isEqualToString:@"saber"]) + return @"sepan"; + if ( [verb isEqualToString:@"haber"]) + return @"hayan"; + + // 2. If the stem of the yo form is exactly the same as the stem of the infinitive, the verb is regular + // Orthographic changes + if ( simplePresentYoStem.length > 2 && + [[simplePresentYoStem substringFromIndex:simplePresentYoStem.length - 2] isEqualToString:@"go"] ) + return [[simplePresentYoStem substringToIndex:simplePresentYoStem.length - 1] stringByAppendingString:@"an"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"car"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"quen"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"gar"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"guen"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"zar"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"c" options:NSBackwardsSearch] withString:@"cen"]; + if ( verb.length > 4 && + [[verb substringFromIndex:verb.length - 4] isEqualToString:@"guir"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"gu" options:NSBackwardsSearch] withString:@"gan"]; + if ( verb.length > 3 && + [[verb substringFromIndex:verb.length - 3] isEqualToString:@"gir"] ) + return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"g" options:NSBackwardsSearch] withString:@"jan"]; + + + + if ( [verbStem isEqualToString:simplePresentYoStem]) { + if ( [verbExit isEqualToString:@"ar"] ) + return [verbStem stringByAppendingString:@"en"]; + else + return [verbStem stringByAppendingString:@"an"]; + } + + // 3. If the stem of the yo form shows a stem change when compared to the stem of the infinitive, + // and it's an -ar or -er verb,the stem will undergo the same changes as the present indicative + if ( ![verbExit isEqualToString:@"ir"] ) { + + if ( [[self simplePresentEtoIEstemChangersArray] containsObject:verb] || + [[self simplePresentOtoUEstemChangersArray] containsObject:verb] || + [[self simplePresentEtoIstemChangersArray] containsObject:verb] || + [verb isEqualToString:@"jugar"] ) { + + if ( [verb isEqualToString:@"jugar"] ) return @"jueguen"; + + if ( [verbExit isEqualToString:@"ar"] ) + return [simplePresentYoStem stringByAppendingString:@"en"]; + else + return [simplePresentYoStem stringByAppendingString:@"an"]; + } + } + + // 4. if the stem of the yo form when compared to infinitie shows it's an -ir stem changing verb, all + // forms of the present subjunctive will have stem changes + if ( [verbExit isEqualToString:@"ir"] ) { + + if ( [[self simplePresentEtoIEstemChangersArray] containsObject:verb] || + [[self simplePresentOtoUEstemChangersArray] containsObject:verb] || + [[self simplePresentEtoIstemChangersArray] containsObject:verb] ) { + + return [simplePresentYoStem stringByAppendingString:@"an"]; + } + } + + // 5. Changing stem in yo form and not a stem changing verb,: use this stem for all forms of + // present subjuntive + if ( [verbExit isEqualToString:@"ar"] ) + return [simplePresentYoStem stringByAppendingString:@"en"]; + else + return [simplePresentYoStem stringByAppendingString:@"an"]; + } + + return verb; +} + + +# pragma mark - Simple Past + - (NSString *) conjugateSimplePastVerb:(NSString *) verb inPerson:(NSString *) person { NSString * verbStem = [self getStem:verb]; @@ -319,14 +854,14 @@ if ( [verb isEqualToString:@"dar"]) return @"di"; if ( [verb isEqualToString:@"ir"] || [verb isEqualToString:@"ser"] ) return @"fui"; - if ( [[verb substringFromIndex:[verb length] - 3] isEqualToString:@"car"] ) - return [[verb substringFromIndex:[verb length] - 3] stringByAppendingString:@"qué"]; + if ( verb.length > 3 && [[verb substringFromIndex:[verb length] - 3] isEqualToString:@"car"] ) + return [[verb substringToIndex:[verb length] - 3] stringByAppendingString:@"qué"]; - if ( [[verb substringFromIndex:[verb length] - 3] isEqualToString:@"gar"] ) - return [[verb substringFromIndex:[verb length] - 3] stringByAppendingString:@"gué"]; + if ( verb.length > 3 && [[verb substringFromIndex:[verb length] - 3] isEqualToString:@"gar"] ) + return [[verb substringToIndex:[verb length] - 3] stringByAppendingString:@"gué"]; - if ( [[verb substringFromIndex:[verb length] - 3] isEqualToString:@"zar"] ) - return [[verb substringFromIndex:[verb length] - 3] stringByAppendingString:@"cé"]; + if ( verb.length > 3 && [[verb substringFromIndex:[verb length] - 3] isEqualToString:@"zar"] ) + return [[verb substringToIndex:[verb length] - 3] stringByAppendingString:@"cé"]; if ( [verbStem isEqualToString:[self getStem:verb]]) { // Regular @@ -334,8 +869,7 @@ else return [verbStem stringByAppendingString:@"í"]; } else { // Irregular - if ( [@"ar" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"e"]; - else return [verbStem stringByAppendingString:@"i"]; + return [verbStem stringByAppendingString:@"e"]; } } @@ -345,8 +879,14 @@ if ( [verb isEqualToString:@"dar"]) return @"diste"; if ( [verb isEqualToString:@"ir"] || [verb isEqualToString:@"ser"] ) return @"fuiste"; - if ( [@"ar" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"aste"]; - else return [verbStem stringByAppendingString:@"iste"]; + if ( [verbStem isEqualToString:[self getStem:verb]]) { + // Regular + if ( [@"ar" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"aste"]; + else return [verbStem stringByAppendingString:@"iste"]; + } else { + // Irregular + return [verbStem stringByAppendingString:@"iste"]; + } } if ( [person isEqualToString:@"THIRD_PERSON_SINGULAR"]) { @@ -354,64 +894,87 @@ if ( [verb isEqualToString:@"dar"]) return @"dio"; if ( [verb isEqualToString:@"ir"] || [verb isEqualToString:@"ser"] ) return @"fue"; - if ( [[verbStem substringFromIndex:[verbStem length] - 1] isEqualToString:@"e"] || + if ( verb.length > 1 && + ([[verbStem substringFromIndex:[verbStem length] - 1] isEqualToString:@"e"] || [[verbStem substringFromIndex:[verbStem length] - 1] isEqualToString:@"i"]) + ) // If the stem of an -er or -ir ends in a vowel, the -i of the 3rd person changes to y return [verbStem stringByAppendingString:@"yó"]; - if ( ![@"ar" isEqualToString:verbExit] ) { + if ( ![verbStem isEqualToString:[self getStem:verb]]) { // Irregular, stem changed - - if ( [@"ar" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"o"]; - else return [verbStem stringByAppendingString:@"io"]; + return [verbStem stringByAppendingString:@"o"]; } if ( [[self simplePresentEtoIEstemChangersArray] containsObject:verb] ) { // Verb changes stem from e to i - verbStem = [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e"] withString:@"i"]; + verbStem = [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"]; } if ( [[self simplePresentOtoUEstemChangersArray] containsObject:verb] ) { // Verb changes stem from o to u - verbStem = [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o"] withString:@"u"]; + verbStem = [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"u"]; } if ( [[self simplePresentEtoIstemChangersArray] containsObject:verb] ) { // Verb changes stem from e to i - verbStem = [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e"] withString:@"i"]; + verbStem = [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"]; } - + + // Regular if ( [@"ar" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"ó"]; - else if ([[verbStem substringFromIndex:[verb length] - 1] isEqualToString:@"i"]) return [verbStem stringByAppendingString:@"o"]; - else return [verbStem stringByAppendingString:@"ió"]; + else if ( verbStem.length > 1 && [[verbStem substringFromIndex:[verbStem length] - 1] isEqualToString:@"i"]) return [verbStem stringByAppendingString:@"yo"]; + else if ( verbStem.length > 1 && [[verbStem substringFromIndex:[verbStem length] - 1] isEqualToString:@"e"]) return [verbStem stringByAppendingString:@"yo"]; + else return [verbStem stringByAppendingString:@"ió"]; } if ( [person isEqualToString:@"FIRST_PERSON_PLURAL"]) { // Irregular if ( [verb isEqualToString:@"dar"]) return @"dimos"; if ( [verb isEqualToString:@"ir"] || [verb isEqualToString:@"ser"] ) return @"fuimos"; - if ( [@"ar" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"amos"]; - else return [verbStem stringByAppendingString:@"imos"]; + if ( [verbStem isEqualToString:[self getStem:verb]]) { + // Regular + if ( [@"ar" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"amos"]; + else return [verbStem stringByAppendingString:@"imos"]; + } else { + // Irregular + return [verbStem stringByAppendingString:@"imos"]; + } } if ( [person isEqualToString:@"SECOND_PERSON_PLURAL"]) { // Irregular if ( [verb isEqualToString:@"dar"]) return @"disteis"; if ( [verb isEqualToString:@"ir"] || [verb isEqualToString:@"ser"] ) return @"fuisteis"; - if ( [@"ar" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"asteis"]; - else return [verbStem stringByAppendingString:@"isteis"]; + if ( [verbStem isEqualToString:[self getStem:verb]]) { + // Regular + if ( [@"ar" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"asteis"]; + else return [verbStem stringByAppendingString:@"isteis"]; + } else { + // Irregular + return [verbStem stringByAppendingString:@"isteis"]; + } } if ( [person isEqualToString:@"THIRD_PERSON_PLURAL"]) { // Irregular if ( [verb isEqualToString:@"dar"]) return @"dieron"; if ( [verb isEqualToString:@"ir"] || [verb isEqualToString:@"ser"] ) return @"fueron"; - if ( [@"ar" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"aron"]; - else if ([[verbStem substringFromIndex:[verbStem length] - 1] isEqualToString:@"j"]) return [verbStem stringByAppendingString:@"eron"]; - else return [verbStem stringByAppendingString:@"ieron"]; + if ( [verbStem isEqualToString:[self getStem:verb]]) { + // Regular + if ( [@"ar" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"aron"]; + else if ( verbStem.length > 1 && [[verbStem substringFromIndex:[verbStem length] - 1] isEqualToString:@"j"]) return [verbStem stringByAppendingString:@"eron"]; + else if ( verbStem.length > 1 && [[verbStem substringFromIndex:[verbStem length] - 1] isEqualToString:@"i"]) return [verbStem stringByAppendingString:@"yeron"]; + else if ( verbStem.length > 1 && [[verbStem substringFromIndex:[verbStem length] - 1] isEqualToString:@"e"]) return [verbStem stringByAppendingString:@"yeron"]; + else return [verbStem stringByAppendingString:@"ieron"]; + } else { + if ( verbStem.length > 1 && [[verbStem substringFromIndex:[verbStem length] - 1] isEqualToString:@"j"]) return [verbStem stringByAppendingString:@"eron"]; + else return [verbStem stringByAppendingString:@"ieron"]; + } } return verb; } +# pragma mark - Imperfect - (NSString *) conjugateImperfectVerb:(NSString *) verb inPerson:(NSString *) person { @@ -472,6 +1035,44 @@ } + +- (NSString *) conjugateImperfectSubjunctiveVerb:(NSString *) verb inPerson:(NSString *) person { + + NSString * verbExit = [self getExit:verb]; + NSString * verbStem = nil; + NSString * imperfect = [self conjugateSimplePastVerb:verb inPerson:@"THIRD_PERSON_PLURAL"]; + + if ( imperfect.length > 2 ) + verbStem = [imperfect substringToIndex:imperfect.length-2]; + + + // regular + if ( [person isEqualToString:@"FIRST_PERSON_SINGULAR"]) { + return [verbStem stringByAppendingString:@"a"]; + } + if ( [person isEqualToString:@"SECOND_PERSON_SINGULAR"]) { + return [verbStem stringByAppendingString:@"as"]; } + if ( [person isEqualToString:@"THIRD_PERSON_SINGULAR"]) { + return [verbStem stringByAppendingString:@"a"]; } + if ( [person isEqualToString:@"FIRST_PERSON_PLURAL"]) { + if ([[verbStem substringFromIndex:verbStem.length-2] isEqualToString:@"ar"]) + verbStem = [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"ar" options:NSBackwardsSearch] withString:@"ár"]; + else + verbStem = [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"er" options:NSBackwardsSearch] withString:@"ér"]; + return [verbStem stringByAppendingString:@"amos"];; + } + if ( [person isEqualToString:@"SECOND_PERSON_PLURAL"]) { + return [verbStem stringByAppendingString:@"ais"]; } + if ( [person isEqualToString:@"THIRD_PERSON_PLURAL"]) { + return [verbStem stringByAppendingString:@"an"]; + } + + return verb; + +} + +# pragma mark - Future / Condicional + // Get stem for Future and Condicional - (NSString *) getFutureStem:(NSString *) verb { @@ -545,31 +1146,35 @@ return verb; } +# pragma mark - Perfect + - (NSString *) conjugatePerfectVerb:(NSString *) verb { NSString * verbStem = [self getStem:verb]; NSString * verbExit = [self getExit:verb]; if ( [verb rangeOfString:@"abrir"].location != NSNotFound) - return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"abrir"] withString:@"abierto"]; + return [verb stringByReplacingCharactersInRange:[verb rangeOfString:@"abrir"] withString:@"abierto"]; if ( [verb rangeOfString:@"cubrir"].location != NSNotFound) - return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"cubrir"] withString:@"cubierto"]; + return [verb stringByReplacingCharactersInRange:[verb rangeOfString:@"cubrir"] withString:@"cubierto"]; if ( [verb rangeOfString:@"decir"].location != NSNotFound) - return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"decir"] withString:@"dicho"]; + return [verb stringByReplacingCharactersInRange:[verb rangeOfString:@"decir"] withString:@"dicho"]; if ( [verb rangeOfString:@"escribir"].location != NSNotFound) - return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"escribir"] withString:@"escrito"]; + return [verb stringByReplacingCharactersInRange:[verb rangeOfString:@"escribir"] withString:@"escrito"]; if ( [verb rangeOfString:@"hacer"].location != NSNotFound) - return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"hacer"] withString:@"hecho"]; + return [verb stringByReplacingCharactersInRange:[verb rangeOfString:@"hacer"] withString:@"hecho"]; if ( [verb rangeOfString:@"morir"].location != NSNotFound) - return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"morir"] withString:@"muerto"]; + return [verb stringByReplacingCharactersInRange:[verb rangeOfString:@"morir"] withString:@"muerto"]; if ( [verb rangeOfString:@"poner"].location != NSNotFound) - return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"poner"] withString:@"puesto"]; + return [verb stringByReplacingCharactersInRange:[verb rangeOfString:@"poner"] withString:@"puesto"]; if ( [verb rangeOfString:@"romper"].location != NSNotFound) - return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"romper"] withString:@"roto"]; + return [verb stringByReplacingCharactersInRange:[verb rangeOfString:@"romper"] withString:@"roto"]; if ( [verb rangeOfString:@"volver"].location != NSNotFound) - return [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"volver"] withString:@"vuelto"]; + return [verb stringByReplacingCharactersInRange:[verb rangeOfString:@"volver"] withString:@"vuelto"]; if ( [verb isEqualToString:@"ver"]) return @"visto"; if ( [@"ar" isEqualToString:verbExit] ) return [verbStem stringByAppendingString:@"ado"]; + else if ( [@"ír" isEqualToString:verbExit] ) + return [verbStem stringByAppendingString:@"ído"]; else return [verbStem stringByAppendingString:@"ido"]; return verb; @@ -583,11 +1188,27 @@ } +// El perfecto de subjuntivo +- (NSString *) conjugatePerfectSubjunctiveVerb:(NSString *) verb inPerson:(NSString *) person { + + // Present of haber + Perfect tense + return [[[self conjugatePresentSubjunctiveVerb:@"haber" inPerson:person] stringByAppendingString:@" "] stringByAppendingString:[self conjugatePerfectVerb:verb]]; + +} + // el pluscuamperfecto - (NSString *) conjugatePastPerfectVerb:(NSString *) verb inPerson:(NSString *) person { // Past of haber + Perfect tense - return [[[self conjugateSimplePastVerb:@"haber" inPerson:person] stringByAppendingString:@" "] stringByAppendingString:[self conjugatePerfectVerb:verb]]; + return [[[self conjugateImperfectVerb:@"haber" inPerson:person] stringByAppendingString:@" "] stringByAppendingString:[self conjugatePerfectVerb:verb]]; + +} + +// el pluscuamperfecto de subjuntivo +- (NSString *) conjugatePastPerfectSubjunctiveVerb:(NSString *) verb inPerson:(NSString *) person { + + // Past of haber + Perfect tense + return [[[self conjugateImperfectSubjunctiveVerb:@"haber" inPerson:person] stringByAppendingString:@" "] stringByAppendingString:[self conjugatePerfectVerb:verb]]; } @@ -606,6 +1227,8 @@ return [[[self conjugateConditionalVerb:@"haber" inPerson:person] stringByAppendingString:@" "] stringByAppendingString:[self conjugatePerfectVerb:verb]]; } +# pragma mark - Gerund + - (NSString *) conjugateGerundVerb:(NSString *) verb inPerson:(NSString *) person { NSString * verbStem = [self getStem:verb]; @@ -614,24 +1237,25 @@ // Irregular if ( [verb isEqualToString:@"ir"]) return @"yendo"; - if ( [[verbStem substringFromIndex:[verb length] - 1] isEqualToString:@"a"] || + if ( verbStem.length > 1 && ( + [[verbStem substringFromIndex:[verb length] - 1] isEqualToString:@"a"] || [[verbStem substringFromIndex:[verb length] - 1] isEqualToString:@"e"] || - [[verbStem substringFromIndex:[verb length] - 1] isEqualToString:@"i"]) + [[verbStem substringFromIndex:[verb length] - 1] isEqualToString:@"i"])) // If the stem of an -er or -ir ends in a vowel, the -i of the 3rd person changes to y return [verbStem stringByAppendingString:@"yendo"]; if ( [[self simplePresentEtoIEstemChangersArray] containsObject:verb] ) { // Verb changes stem from e to i - verbStem = [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e"] withString:@"i"]; + verbStem = [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"]; } if ( [[self simplePresentOtoUEstemChangersArray] containsObject:verb] ) { // Verb changes stem from o to u - verbStem = [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o"] withString:@"u"]; + verbStem = [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"u"]; } if ( [[self simplePresentEtoIstemChangersArray] containsObject:verb] ) { // Verb changes stem from e to i - verbStem = [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e"] withString:@"i"]; + verbStem = [verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"]; } // Regular @@ -641,34 +1265,1907 @@ return verb; } +# pragma mark - Conjugate Verb + - (NSString *) conjugateVerb:(NSString *) verb inPerson:(NSString *) person andTense:(Tense *) tense { + BOOL reflexive = FALSE; + NSString * conjugated = nil; + + if ( [[self getExit:verb] isEqualToString:@"se"] ) { + reflexive = TRUE; + // Getting the stem will remove the last 2 characters + verb = [self getStem:verb]; + } if ( [tense.tense isEqualToString:@"SIMPLE_PRESENT"]) - return [self conjugateSimplePresentVerb:verb inPerson:person]; + conjugated = [self conjugateSimplePresentVerb:verb inPerson:person]; + else if ( [tense.tense isEqualToString:@"PRESENT_SUBJUNCTIVE"]) + conjugated = [self conjugatePresentSubjunctiveVerb:verb inPerson:person]; else if ( [tense.tense isEqualToString:@"SIMPLE_PAST"]) - return [self conjugateSimplePastVerb:verb inPerson:person]; + conjugated = [self conjugateSimplePastVerb:verb inPerson:person]; else if ( [tense.tense isEqualToString:@"IMPERFECT"]) - return [self conjugateImperfectVerb:verb inPerson:person]; + conjugated = [self conjugateImperfectVerb:verb inPerson:person]; + else if ( [tense.tense isEqualToString:@"IMPERFECT_SUBJUNCTIVE"]) + conjugated = [self conjugateImperfectSubjunctiveVerb:verb inPerson:person]; else if ( [tense.tense isEqualToString:@"FUTURE"]) - return [self conjugateFutureVerb:verb inPerson:person]; + conjugated = [self conjugateFutureVerb:verb inPerson:person]; else if ( [tense.tense isEqualToString:@"PERFECT"]) - return [self conjugatePerfectVerb:verb]; + conjugated = [self conjugatePerfectVerb:verb]; else if ( [tense.tense isEqualToString:@"PRESENT_PERFECT"]) - return [self conjugatePresentPerfectVerb:verb inPerson:person]; + conjugated = [self conjugatePresentPerfectVerb:verb inPerson:person]; + else if ( [tense.tense isEqualToString:@"PERFECT_SUBJUNCTIVE"]) + conjugated = [self conjugatePerfectSubjunctiveVerb:verb inPerson:person]; else if ( [tense.tense isEqualToString:@"PAST_PERFECT"]) // Pluscuamperfecto - return [self conjugatePastPerfectVerb:verb inPerson:person]; + conjugated = [self conjugatePastPerfectVerb:verb inPerson:person]; + else if ( [tense.tense isEqualToString:@"PAST_PERFECT_SUBJUNCTIVE"]) // Pluscuamperfecto de subjuntivo + conjugated = [self conjugatePastPerfectSubjunctiveVerb:verb inPerson:person]; else if ( [tense.tense isEqualToString:@"FUTURE_PERFECT"]) - return [self conjugateFuturePerfectVerb:verb inPerson:person]; + conjugated = [self conjugateFuturePerfectVerb:verb inPerson:person]; else if ( [tense.tense isEqualToString:@"CONDITIONAL_PERFECT"]) - return [self conjugateConditionalPerfectVerb:verb inPerson:person]; + conjugated = [self conjugateConditionalPerfectVerb:verb inPerson:person]; else if ( [tense.tense isEqualToString:@"CONDITIONAL"]) - return [self conjugateConditionalVerb:verb inPerson:person]; + conjugated = [self conjugateConditionalVerb:verb inPerson:person]; else if ( [tense.tense isEqualToString:@"GERUND"]) - return [self conjugateGerundVerb:verb inPerson:person]; + conjugated = [self conjugateGerundVerb:verb inPerson:person]; else return @"Invalid tense"; + if ( reflexive ) { + NSLog(@"%@",[[[[self reflexivePersons] objectForKey:person] stringByAppendingString:@" "] stringByAppendingString:conjugated]); + return [[[[self reflexivePersons] objectForKey:person] stringByAppendingString:@" "] stringByAppendingString:conjugated]; + } + else { + return conjugated; + } + +} + +#pragma mark - Generate test answers + +- (NSMutableArray *)addToAnswers:(NSMutableArray *)answers withCorrectAnswer:(NSString *) correct conjugation:(NSString *) conjugation +{ + if ( [conjugation isEqualToString:correct]) + return answers; + else + // Check if answer already exists in array + for ( NSString * a in answers) { + if ( [a isEqualToString:conjugation]) return answers; + } + [answers addObject:conjugation]; + return answers; +} + +- (id) popLastFromArray:(NSMutableArray *)a +{ + id lastObject = nil; + if ( a && a.count > 0 ) { + lastObject = [a lastObject]; + NSLog(@"Popping: %@", lastObject); + [a removeLastObject]; + } + return lastObject; +} + +- (NSMutableArray *)generateFalseConjugationsSimplePresentVerb:(NSString *) verb inPerson:(NSString *)person withCorrectAnswer:(NSString *)correct +{ + NSMutableArray *answers = [[NSMutableArray alloc] init]; + NSString *verbExit = [self getExit:verb]; + NSString *verbStem = [self getStem:verb]; + + if ( [person isEqualToString:@"FIRST_PERSON_SINGULAR"]) { + + if ( [verb isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vaya"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"ido"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayo"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vaye"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"ido"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"ide"]; + } + if ( ![verb isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"a"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"e"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ó"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"é"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"í"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ió"]]; + } + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"o"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"o"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"o"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"o"]]; + + if ( [verbExit isEqualToString:@"er"] ) { + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"e"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"e"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"e"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"e"]]; + } + + if ( [verbExit isEqualToString:@"ir"] ) { + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"i"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"i"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"i"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"i"]]; + } + + } else if ( [person isEqualToString:@"SECOND_PERSON_SINGULAR"] ) { + + if ( [verb isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayas"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"idas"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayes"]; + } + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"as"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"es"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"is"]]; + + if ( [verbExit isEqualToString:@"ar"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"aste"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"abas"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"iste"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"íais"]]; + } + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"s"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"as"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"as"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"as"]]; + + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"es"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"es"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"es"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"es"]]; + + if ( [verbExit isEqualToString:@"ir"] ) { + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"is"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"is"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"is"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"is"]]; + } + + } else if ( [person isEqualToString:@"THIRD_PERSON_SINGULAR"]) { + + if ( [verb isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vaya"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"idas"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayo"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"ido"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"ide"]; + } + if ( ![verb isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"a"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"á"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"e"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"o"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"é"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"í"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ió"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"aba"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ía"]]; + } + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"o"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"o"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"o"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"o"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"e"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"e"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"e"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"e"]]; + + } else if ( [person isEqualToString:@"FIRST_PERSON_PLURAL"]) { + + if ( [verb isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayamos"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"idamos"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"idemos"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayemos"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"idemos"]; + } + + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"amos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"emos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"imos"]]; + + if ( [verbExit isEqualToString:@"ar"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"abamos"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"íais"]]; + } + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"amos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"amos"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"amos"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"amos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"emos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"emos"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"emos"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"emos"]]; + + } else if ( [person isEqualToString:@"SECOND_PERSON_PLURAL"] ) { + + if ( [verb isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayáis"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"idáis"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"idáis"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayéis"]; + } + + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"áis"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"aís"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"éis"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"eís"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"is"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ís"]]; + + if ( [verbExit isEqualToString:@"ar"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"abais"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"abas"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"íais"]]; + } + + if ( [verbExit isEqualToString:@"ar"] ) { + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"áis"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"áis"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"áis"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"áis"]]; + } + if ( [verbExit isEqualToString:@"er"] ) { + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"éis"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"éis"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"éis"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"éis"]]; + } + if ( [verbExit isEqualToString:@"ir"] ) { + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"ís"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"ís"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"ís"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"ís"]]; + } + } else if ( [person isEqualToString:@"THIRD_PERSON_PLURAL"]) { + + if ( [verb isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayan"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"iden"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"idan"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayen"]; + } + + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"an"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"en"]]; + + if ( [verbExit isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"in"]]; + } + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ieron"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"aban"]]; + + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"en"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"en"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"en"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"en"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"an"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"an"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"an"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"an"]]; + + + } else { + answers = [[NSMutableArray alloc] initWithObjects:@"Answer 1",@"Answer 2",@"Answer 3", @"Answer 4", nil]; + } + + [answers shuffle]; + return [answers mutableCopy]; } +- (NSMutableArray *)generateFalseConjugationsSimplePastVerb:(NSString *) verb inPerson:(NSString *)person withCorrectAnswer:(NSString *)correct +{ + NSMutableArray *answers = [[NSMutableArray alloc] init]; + NSString *verbExit = [self getExit:verb]; + NSString *verbStem = [self getStem:verb]; + + if ( [person isEqualToString:@"FIRST_PERSON_SINGULAR"]) { + + if ( [verb isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"fue"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vaye"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayó"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"fí"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"iba"]; + } + + if ( ![verb isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"a"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"e"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ó"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"é"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"í"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ió"]]; + } + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"é"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"é"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"é"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"é"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"í"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"í"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"í"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"í"]]; + + + } else if ( [person isEqualToString:@"SECOND_PERSON_SINGULAR"] ) { + + if ( [verb isEqualToString:@"ir"] || [verb isEqualToString:@"ser"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"fueste"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayaste"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayeste"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"fiësta"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"ibaste"]; + } + + if ( [verbExit isEqualToString:@"ar"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"as"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"es"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"is"]]; + } + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"aste"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"abas"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"iste"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"íais"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"aste"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"aste"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"aste"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"aste"]]; + + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"iste"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"iste"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"iste"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"iste"]]; + + } else if ( [person isEqualToString:@"THIRD_PERSON_SINGULAR"]) { + + + if ( [verb isEqualToString:@"ir"] || [verb isEqualToString:@"ser"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"fui"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayó"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vaye"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"fiëstó"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"iba"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"iró"]; + } + if ( ![verb isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"a"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"á"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"e"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"o"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"é"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"í"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ió"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"aba"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ía"]]; + } + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"o"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"o"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"o"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"o"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"ío"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"ío"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"ío"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"ío"]]; + + } else if ( [person isEqualToString:@"FIRST_PERSON_PLURAL"]) { + + if ( [verb isEqualToString:@"ir"] || [verb isEqualToString:@"ser"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"fuemos"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayemos"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayamos"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"fiëstamos"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"ibamos"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"iramos"]; + } + + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"amos"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"emos"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"imos"]]; + + if ( [verbExit isEqualToString:@"ar"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"abamos"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"íais"]]; + } + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"amos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"amos"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"amos"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"amos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"emos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"emos"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"emos"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"emos"]]; + + if ( ![verbExit isEqualToString:@"ar"] ) { + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"imos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"imos"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"imos"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"imos"]]; + + } + + } else if ( [person isEqualToString:@"SECOND_PERSON_PLURAL"] ) { + + if ( [verb isEqualToString:@"ir"] || [verb isEqualToString:@"ser"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"fuesteis"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayesteis"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayasteis"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"fiëstasteis"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"ibeis"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"ireis"]; + } + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"astáis"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"asteis"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"astais"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"esteis"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"estéis"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"isteis"]]; + + + if ( [verbExit isEqualToString:@"ar"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"abais"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"abas"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"áis"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"aís"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"íais"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"éis"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"eís"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"is"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ís"]]; + } + + if ( [verbExit isEqualToString:@"ar"] ) { + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"astáis"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"astáis"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"astáis"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"astáis"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"astais"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"astais"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"astais"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"astais"]]; + + } + if ( [verbExit isEqualToString:@"er"] ) { + + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"esteis"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"esteis"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"esteis"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"esteis"]]; + + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"estéis"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"estéis"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"estéis"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"estéis"]]; + } + if ( ![verbExit isEqualToString:@"ar"] ) { + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"ísteis"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"ísteis"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"ísteis"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"ísteis"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"isteis"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"isteis"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"isteis"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"isteis"]]; + } + } else if ( [person isEqualToString:@"THIRD_PERSON_PLURAL"]) { + + if ( [verb isEqualToString:@"ir"] || [verb isEqualToString:@"ser"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"fuiron"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayaron"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayeron"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"fieron"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"ibaron"]; + } + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"an"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"en"]]; + + if ( [verbExit isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"in"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"iron"]]; + } + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ieron"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"eron"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"aron"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"aban"]]; + + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"aron"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"aron"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"aron"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"aron"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"eron"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"eron"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"eron"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"eron"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"ieron"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"ieron"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"ieron"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"ieron"]]; + + } else { + answers = [[NSMutableArray alloc] initWithObjects:@"Answer 1",@"Answer 2",@"Answer 3", @"Answer 4", nil]; + } + + [answers shuffle]; + return [answers mutableCopy]; +} + + + +- (NSMutableArray *)generateFalseConjugationsImperfectVerb:(NSString *) verb inPerson:(NSString *)person withCorrectAnswer:(NSString *)correct +{ + NSMutableArray *answers = [[NSMutableArray alloc] init]; + NSString *verbExit = [self getExit:verb]; + NSString *verbStem = [self getStem:verb]; + + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[self conjugateImperfectSubjunctiveVerb:verb inPerson:person]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[self conjugateImperfectVerb:verb inPerson:person]]; + + if ( [person isEqualToString:@"FIRST_PERSON_SINGULAR"] || + [person isEqualToString:@"THIRD_PERSON_SINGULAR"] ) { + + if ( [verb isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"fue"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vaye"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"vayó"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"fí"]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:@"iba"]; + } + + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"a"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"e"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"í"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ió"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"aba"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ía"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ia"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"aba"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"aba"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"aba"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"aba"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"ía"]]; + + + } else if ( [person isEqualToString:@"SECOND_PERSON_SINGULAR"] ) { + + if ( [verbExit isEqualToString:@"ar"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"as"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"es"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"is"]]; + } + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ias"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ías"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"iás"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"íais"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"abas"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"abas"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"abas"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"abas"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"abas"]]; + + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"ías"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"ías"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"ías"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"ías"]]; + + } else if ( [person isEqualToString:@"FIRST_PERSON_PLURAL"]) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"amos"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"emos"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"imos"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"abamos"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ábamos"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"iamos"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"íamos"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"íais"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"ábamos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"ábamos"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"ábamos"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"ábamos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"íamos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"íamos"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"íamos"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"íamos"]]; + + + } else if ( [person isEqualToString:@"SECOND_PERSON_PLURAL"] ) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"asteis"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"astais"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"abais"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ábais"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"abaís"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"íais"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"iaís"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"isteis"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"áis"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"éis"]]; + + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"abais"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"abais"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"abais"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"abais"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"íais"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"íais"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"íais"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"íais"]]; + + } else if ( [person isEqualToString:@"THIRD_PERSON_PLURAL"]) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"an"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"en"]]; + + if ( [verbExit isEqualToString:@"ir"] ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"in"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"iron"]]; + } + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ieron"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"eron"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"aron"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"aban"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ían"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ián"]]; + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ian"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"aban"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"aban"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"aban"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"aban"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"ían"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"ían"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"ían"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"ían"]]; + + } else { + answers = [[NSMutableArray alloc] initWithObjects:@"Answer 1",@"Answer 2",@"Answer 3", @"Answer 4", nil]; + } + + [answers shuffle]; + return [answers mutableCopy]; +} + + +- (NSMutableArray *)generateFalseConjugationsFutureVerb:(NSString *) verb inPerson:(NSString *)person withCorrectAnswer:(NSString *)correct +{ + NSMutableArray *answers = [[NSMutableArray alloc] init]; + NSString *verbExit = [self getExit:verb]; + NSString *verbStem = [self getStem:verb]; + + if ( [person isEqualToString:@"FIRST_PERSON_SINGULAR"]) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"é"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"e"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"ó"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"á"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"e"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"ó"]]; + + if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"l"] || + [[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"n"] + )) + { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"dré"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"drá"]]; + } else if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"c"]) + ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"ré"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"rá"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ré"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"rá"]]; + } + + if ( [verbExit isEqualToString:@"ir"]) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"í"]]; + } + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"é"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"é"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"é"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"é"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"á"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"á"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"á"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"á"]]; + + } else if ( [person isEqualToString:@"SECOND_PERSON_SINGULAR"] ) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"as"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"es"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"és"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"ás"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"es"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"és"]]; + + if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"l"] || + [[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"n"] + )) + { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"drés"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"drás"]]; + } else if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"c"]) + ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"rés"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"rás"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"rés"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"rás"]]; + } + + if ( [verbExit isEqualToString:@"ir"]) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"ís"]]; + } + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"és"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"és"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"és"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"és"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"ás"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"ás"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ás"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ás"]]; + + } else if ( [person isEqualToString:@"THIRD_PERSON_SINGULAR"]) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"a"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"é"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"ó"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"a"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"é"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"ó"]]; + + if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"l"] || + [[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"n"] + )) + { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"dré"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"drá"]]; + } else if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"c"]) + ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"ré"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"rá"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ré"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"rá"]]; + } + + if ( [verbExit isEqualToString:@"ir"]) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"í"]]; + } + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"é"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"é"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"é"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"é"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"á"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"á"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"á"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"á"]]; + + } else if ( [person isEqualToString:@"FIRST_PERSON_PLURAL"]) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"amos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"imos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"abamos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"amos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"imos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"abamos"]]; + + if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"l"] || + [[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"n"] + )) + { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"dremos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"dramos"]]; + } else if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"c"]) + ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"remos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"ramos"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"remos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ramos"]]; + } + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"emos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"emos"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"emos"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"emos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"emos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"emos"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"emos"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"emos"]]; + + + } else if ( [person isEqualToString:@"SECOND_PERSON_PLURAL"] ) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"eís"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"áis"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"aís"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"abáis"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"áis"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"éis"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"abáis"]]; + + if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"l"] || + [[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"n"] + )) + { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"dréis"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"dráis"]]; + } else if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"c"]) + ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"réis"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"réis"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"réis"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"réis"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ráis"]]; + } + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"éis"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"éis"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"éis"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"éis"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"áis"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"áis"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"áis"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"áis"]]; + + + } else if ( [person isEqualToString:@"THIRD_PERSON_PLURAL"]) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"én"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"an"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"en"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"én"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"án"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"en"]]; + + if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"l"] || + [[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"n"] + )) + { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"drán"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"dran"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"dren"]]; + } else if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"c"]) + ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"rán"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"ran"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"ren"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"rán"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ran"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ren"]]; + } + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"én"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"én"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"én"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"én"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"án"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"án"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"án"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"án"]]; + + } else { + answers = [[NSMutableArray alloc] initWithObjects:@"Answer 1",@"Answer 2",@"Answer 3", @"Answer 4", nil]; + } + + [answers shuffle]; + return [answers mutableCopy]; +} + +- (NSMutableArray *)generateFalseConjugationsConditionalVerb:(NSString *) verb inPerson:(NSString *)person withCorrectAnswer:(NSString *)correct +{ + NSMutableArray *answers = [[NSMutableArray alloc] init]; + NSString *verbExit = [self getExit:verb]; + NSString *verbStem = [self getStem:verb]; + + if ( [person isEqualToString:@"FIRST_PERSON_SINGULAR"]) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"é"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"ia"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"a"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ía"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"á"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"ía"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"é"]]; + + if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"l"] || + [[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"n"] + )) + { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"dría"]]; + } else if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"c"]) + ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"ría"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ría"]]; + } + + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + } else if ( [person isEqualToString:@"SECOND_PERSON_SINGULAR"] ) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"és"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"ias"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"as"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ías"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"as"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"ias"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"é"]]; + + if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"l"] || + [[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"n"] + )) + { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"drías"]]; + } else if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"c"]) + ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"rías"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"rías"]]; + } + + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"ías"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"ías"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ías"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ías"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"ías"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"ías"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ías"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ías"]]; + + } else if ( [person isEqualToString:@"THIRD_PERSON_SINGULAR"]) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"é"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"ia"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"a"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ía"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"á"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"ía"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"é"]]; + + if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"l"] || + [[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"n"] + )) + { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"dría"]]; + } else if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"c"]) + ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"ría"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ría"]]; + } + + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ía"]]; + + } else if ( [person isEqualToString:@"FIRST_PERSON_PLURAL"]) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"émos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"iamos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"amas"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"íamos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"ámos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"íamos"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"émos"]]; + + if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"l"] || + [[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"n"] + )) + { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"dríamos"]]; + } else if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"c"]) + ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"ríamos"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ríamos"]]; + } + + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"íamos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"íamos"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"íamos"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"íamos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"íamos"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"íamos"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"íamos"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"íamos"]]; + + } else if ( [person isEqualToString:@"SECOND_PERSON_PLURAL"] ) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"eís"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"áis"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"aís"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"abáis"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"íais"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"ás"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"íais"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"íeis"]]; + + if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"l"] || + [[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"n"] + )) + { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"dríais"]]; + } else if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"c"]) + ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"ríais"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ríais"]]; + } + + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"íais"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"íais"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"íais"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"íais"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"íais"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"íais"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"íais"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"íais"]]; + + } else if ( [person isEqualToString:@"THIRD_PERSON_PLURAL"]) { + + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"én"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"ian"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verb stringByAppendingString:@"an"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"ía"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"án"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"ían"]]; + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[self getFutureStem:verb] stringByAppendingString:@"én"]]; + + if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"l"] || + [[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"n"] + )) + { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"drían"]]; + } else if ( verbStem.length > 1 && + ([[verbStem substringFromIndex:verbStem.length -1] isEqualToString:@"c"]) + ) { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[verbStem substringToIndex:verbStem.length -1] stringByAppendingString:@"rían"]]; + } else { + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[verbStem stringByAppendingString:@"rían"]]; + } + + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"ían"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"ían"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ían"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ían"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:verbExit] stringByAppendingString:@"ían"]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:verbExit] stringByAppendingString:@"ían"]]; + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ían"]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers withCorrectAnswer:correct conjugation:[[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:verbExit] stringByAppendingString:@"ían"]]; + + } else { + answers = [[NSMutableArray alloc] initWithObjects:@"Answer 1",@"Answer 2",@"Answer 3", @"Answer 4", nil]; + } + + [answers shuffle]; + return [answers mutableCopy]; +} + + + +- (NSMutableArray *)generateFalseConjugationsPerfectVerb:(NSString *) verb withHaberConjugation:(NSString *)haberConj withCorrectAnswer:(NSString *)correct inPerson:(NSString *)person +{ + NSMutableArray *answers = [[NSMutableArray alloc] init]; + NSString *verbExit = [self getExit:verb]; + NSString *verbStem = [self getStem:verb]; + + if ((arc4random() % 2) == 0 ) { + + + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[self conjugateFuturePerfectVerb:verb inPerson:person]]; + + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[self conjugatePastPerfectVerb:verb inPerson:person]]; + + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[self conjugatePresentPerfectVerb:verb inPerson:person]]; + + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[self conjugatePastPerfectSubjunctiveVerb:verb inPerson:person]]; + + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[self conjugatePerfectSubjunctiveVerb:verb inPerson:person]]; + + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[self conjugateConditionalPerfectVerb:verb inPerson:person]]; + + } else { + + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[[haberConj stringByAppendingString:@" "] stringByAppendingString:[verbStem stringByAppendingString:@"ado"]]]; + + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[[haberConj stringByAppendingString:@" "] stringByAppendingString:[verbStem stringByAppendingString:@"ido"]]]; + + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[[haberConj stringByAppendingString:@" "] stringByAppendingString:[verbStem stringByAppendingString:@"endo"]]]; + + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[[haberConj stringByAppendingString:@" "] stringByAppendingString:[verbStem stringByAppendingString:@"iendo"]]]; + + if ( [verbExit isEqualToString:@"ir"]){ + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[[haberConj stringByAppendingString:@" "] stringByAppendingString:[verbStem stringByAppendingString:@"ierto"]]]; + } + + if ( [verbExit isEqualToString:@"ar"]){ + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[[haberConj stringByAppendingString:@" "] stringByAppendingString:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"ado"]]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[[haberConj stringByAppendingString:@" "] stringByAppendingString:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"ado"]]]; + + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[[haberConj stringByAppendingString:@" "] stringByAppendingString:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"ado"]]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[[haberConj stringByAppendingString:@" "] stringByAppendingString:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"ado"]]]; + } else { + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[[haberConj stringByAppendingString:@" "] stringByAppendingString:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"ie"] stringByAppendingString:@"ido"]]]; + + if ( [verbStem rangeOfString:@"e" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[[haberConj stringByAppendingString:@" "] stringByAppendingString:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"e" options:NSBackwardsSearch] withString:@"i"] stringByAppendingString:@"ido"]]]; + + + if ( [verbStem rangeOfString:@"o" options:NSBackwardsSearch].location != NSNotFound) + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[[haberConj stringByAppendingString:@" "] stringByAppendingString:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"o" options:NSBackwardsSearch] withString:@"ue"] stringByAppendingString:@"ido"]]]; + + if ( [verbStem rangeOfString:@"u"].location != NSNotFound) + [self addToAnswers:answers + withCorrectAnswer:correct + conjugation:[[haberConj stringByAppendingString:@" "] stringByAppendingString:[[verbStem stringByReplacingCharactersInRange:[verbStem rangeOfString:@"u"] withString:@"ue"] stringByAppendingString:@"ido"]]]; + } + } + + [answers shuffle]; + return [answers mutableCopy]; +} + +- (NSMutableArray *) getTestConjugationsForVerb:(NSString *) verb inPerson:(NSString *) person andTense:(Tense *) tense { + + BOOL reflexive = FALSE; + + NSLog(@"Getting test conjugation for %@ in person %@ and %@",verb,person,tense); + + if ( [[self getExit:verb] isEqualToString:@"se"] ) { + reflexive = TRUE; + // Getting the stem will remove the last 2 characters + verb = [self getStem:verb]; + } + + NSString * correctAnswer = nil; + NSMutableArray * wrongAnswers = nil; + NSMutableArray * answers = [[NSMutableArray alloc] init]; + + if ( reflexive) { + correctAnswer = [[[[self reflexivePersons] objectForKey:person] stringByAppendingString:@" "] stringByAppendingString:[self conjugateVerb:verb inPerson:person andTense:tense]]; + } else { + correctAnswer = [self conjugateVerb:verb inPerson:person andTense:tense]; + } + + + NSLog(@"Correct answer: %@", correctAnswer); + + if ( [tense.tense isEqualToString:@"SIMPLE_PRESENT"]) + wrongAnswers = [self generateFalseConjugationsSimplePresentVerb:verb inPerson:person withCorrectAnswer:correctAnswer]; + else if ( [tense.tense isEqualToString:@"PRESENT_SUBJUNCTIVE"]) + wrongAnswers = [self generateFalseConjugationsSimplePresentVerb:verb inPerson:person withCorrectAnswer:correctAnswer]; + else if ( [tense.tense isEqualToString:@"SIMPLE_PAST"]) + wrongAnswers = [self generateFalseConjugationsSimplePastVerb:verb inPerson:person withCorrectAnswer:correctAnswer]; + else if ( [tense.tense isEqualToString:@"IMPERFECT"]) + wrongAnswers = [self generateFalseConjugationsImperfectVerb:verb inPerson:person withCorrectAnswer:correctAnswer]; + else if ( [tense.tense isEqualToString:@"IMPERFECT_SUBJUNCTIVE"]) + wrongAnswers = [self generateFalseConjugationsImperfectVerb:verb inPerson:person withCorrectAnswer:correctAnswer]; + else if ( [tense.tense isEqualToString:@"PRESENT_PERFECT"]) + wrongAnswers = [self generateFalseConjugationsPerfectVerb:verb withHaberConjugation:[self conjugateSimplePresentVerb:@"haber" inPerson:person] withCorrectAnswer:correctAnswer inPerson:person]; + else if ( [tense.tense isEqualToString:@"PERFECT_SUBJUNCTIVE"]) + wrongAnswers = [self generateFalseConjugationsPerfectVerb:verb withHaberConjugation:[self conjugatePresentSubjunctiveVerb:@"haber" inPerson:person] withCorrectAnswer:correctAnswer inPerson:person]; + else if ( [tense.tense isEqualToString:@"PAST_PERFECT"]) + wrongAnswers = [self generateFalseConjugationsPerfectVerb:verb withHaberConjugation:[self conjugateImperfectVerb:@"haber" inPerson:person] withCorrectAnswer:correctAnswer inPerson:person]; + else if ( [tense.tense isEqualToString:@"PAST_PERFECT_SUBJUNCTIVE"]) + wrongAnswers = [self generateFalseConjugationsPerfectVerb:verb withHaberConjugation:[self conjugateImperfectSubjunctiveVerb:@"haber" inPerson:person] withCorrectAnswer:correctAnswer inPerson:person]; + else if ( [tense.tense isEqualToString:@"FUTURE"]) + wrongAnswers = [self generateFalseConjugationsFutureVerb:verb inPerson:person withCorrectAnswer:correctAnswer]; + else if ( [tense.tense isEqualToString:@"FUTURE_PERFECT"]) + wrongAnswers = [self generateFalseConjugationsPerfectVerb:verb withHaberConjugation:[self conjugateFutureVerb:@"haber" inPerson:person] withCorrectAnswer:correctAnswer inPerson:person]; + else if ( [tense.tense isEqualToString:@"CONDITIONAL"]) + wrongAnswers = [self generateFalseConjugationsConditionalVerb:verb inPerson:person withCorrectAnswer:correctAnswer]; + else if ( [tense.tense isEqualToString:@"CONDITIONAL_PERFECT"]) + wrongAnswers = [self generateFalseConjugationsPerfectVerb:verb withHaberConjugation:[self conjugateConditionalVerb:@"haber" inPerson:person] withCorrectAnswer:correctAnswer inPerson:person]; + else + wrongAnswers = [[NSMutableArray alloc] initWithObjects:@"Answer 1",@"Answer 2",@"Answer 3", nil]; + + if ( reflexive) { + // Need to correct the wrong answers + NSMutableArray *rAnswers = [[NSMutableArray alloc] init]; + for ( NSString * v in wrongAnswers){ + [rAnswers addObject:[[[[self reflexivePersons] objectForKey:person] stringByAppendingString:@" "] stringByAppendingString:v]]; + } + wrongAnswers = rAnswers; + } + + // Add the correct answer + [answers addObject:correctAnswer]; + + // add 3 wrong answers + [answers addObject:[self popLastFromArray:wrongAnswers]]; + [answers addObject:[self popLastFromArray:wrongAnswers]]; + [answers addObject:[self popLastFromArray:wrongAnswers]]; + + [answers shuffle]; + return [answers mutableCopy]; +} + @end diff --git a/Espagram/Tense.h b/Espagram/Tense.h new file mode 100644 index 0000000..253aa4a --- /dev/null +++ b/Espagram/Tense.h @@ -0,0 +1,17 @@ +// +// Tense.h +// Espagram +// +// Created by Abel Fokkinga on 11/8/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import + +@interface Tense : NSObject + +@property (nonatomic, strong) NSString * tense; + +- (NSString *) getTenseInLanguage:(NSString *)language; + +@end diff --git a/Espagram/Tense.m b/Espagram/Tense.m new file mode 100644 index 0000000..7eab749 --- /dev/null +++ b/Espagram/Tense.m @@ -0,0 +1,73 @@ +// +// Tense.m +// Espagram +// +// Created by Abel Fokkinga on 11/8/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import "Tense.h" + +@interface Tense() +@property (nonatomic, strong) NSDictionary * text; +@end + +@implementation Tense + +@synthesize tense = _tense; +@synthesize text = _text; + +- (void) tense:(NSString *)t { + if ( ![t isEqualToString:_tense]){ + _tense = t; + // reset dictionary + NSLog(@"Resetting tense"); + self.text = nil; + } +} + +- (NSDictionary *) text { + if ( !_text) { + if ( [self.tense isEqualToString:@"SIMPLE_PRESENT"]) + _text = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] + initWithObjects:@"Presente",@"Simple present",@"Onvoltooid tegenwoordige tijd",nil] forKeys:[[NSArray alloc] initWithObjects:@"Spanish",@"English",@"Dutch", nil]]; + if ( [self.tense isEqualToString:@"SIMPLE_PAST"]) + _text = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] + initWithObjects:@"Indefinido",@"Simple past",@"Verleden tijd",nil] forKeys:[[NSArray alloc] initWithObjects:@"Spanish",@"English",@"Dutch", nil]]; + if ( [self.tense isEqualToString:@"IMPERFECT"]) + _text = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] + initWithObjects:@"Imperfecto",@"Imperfect",@"Onvoltooid verleden tijd",nil] forKeys:[[NSArray alloc] initWithObjects:@"Spanish",@"English",@"Dutch", nil]]; + if ( [self.tense isEqualToString:@"FUTURE"]) + _text = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] + initWithObjects:@"Futuro",@"Future",@"Toekomstige tijd",nil] forKeys:[[NSArray alloc] initWithObjects:@"Spanish",@"English",@"Dutch", nil]]; + if ( [self.tense isEqualToString:@"PRESENT_PERFECT"]) + _text = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] + initWithObjects:@"Perfecto",@"Present perfect",@"Pretérito perfecto",nil] forKeys:[[NSArray alloc] initWithObjects:@"Spanish",@"English",@"Dutch", nil]]; + if ( [self.tense isEqualToString:@"PAST_PERFECT"]) + _text = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] + initWithObjects:@"Pluscuamperfecto",@"Past perfect",@"Pretérito pluscuamperfecto",nil] forKeys:[[NSArray alloc] initWithObjects:@"Spanish",@"English",@"Dutch", nil]]; + if ( [self.tense isEqualToString:@"FUTURE_PERFECT"]) + _text = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] + initWithObjects:@"Futuro perfecto",@"Future perfect",@"Pretérito pluscuamperfecto",nil] forKeys:[[NSArray alloc] initWithObjects:@"Spanish",@"English",@"Dutch", nil]]; + if ( [self.tense isEqualToString:@"CONDITIONAL"]) + _text = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] + initWithObjects:@"Condicional",@"Conditional",@"Voorwaardelijke wijs",nil] forKeys:[[NSArray alloc] initWithObjects:@"Spanish",@"English",@"Dutch", nil]]; + if ( [self.tense isEqualToString:@"GERUND"]) + _text = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] + initWithObjects:@"Gerundio",@"Gerund",@"Tegenwoordig deelwoord",nil] forKeys:[[NSArray alloc] initWithObjects:@"Spanish",@"English",@"Dutch", nil]]; + if ( [self.tense isEqualToString:@"IMPERATIVE"]) + _text = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] + initWithObjects:@"Imperativo",@"Imperative",@"Gebiedende wijs",nil] forKeys:[[NSArray alloc] initWithObjects:@"Spanish",@"English",@"Dutch", nil]]; + } + + return _text; +} + +- (NSString *) getTenseInLanguage:(NSString *)language { + return [self.text objectForKey:language]; +} + + + + +@end diff --git a/Espagram/Tenses.h b/Espagram/Tenses.h deleted file mode 100644 index 1095f01..0000000 --- a/Espagram/Tenses.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// Tenses.h -// Espagram -// -// Created by Abel Fokkinga on 8/29/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import -#import - - -@interface Tenses : NSManagedObject - -@property (nonatomic, retain) NSString * tense; -@property (nonatomic, retain) NSString * language; -@property (nonatomic, retain) NSString * translation; - -@end diff --git a/Espagram/Tenses.m b/Espagram/Tenses.m deleted file mode 100644 index cb53cd0..0000000 --- a/Espagram/Tenses.m +++ /dev/null @@ -1,18 +0,0 @@ -// -// Tenses.m -// Espagram -// -// Created by Abel Fokkinga on 8/29/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import "Tenses.h" - - -@implementation Tenses - -@dynamic tense; -@dynamic language; -@dynamic translation; - -@end diff --git a/Espagram/TestBrain.h b/Espagram/TestBrain.h deleted file mode 100644 index cce0b75..0000000 --- a/Espagram/TestBrain.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// TestBrain.h -// Espagram -// -// Created by Abel Fokkinga on 10/20/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import -#import "TestableConjugation.h" - -@interface TestBrain : NSObject - -@property (readonly) NSArray *testVerb; - - -- (NSArray *) testConjugation:(TestableConjugation *) conjugation; - -- (Boolean *) checkAnswer:(NSString *)answer forConjugation:(TestableConjugation *) conjugation; - - -@end diff --git a/Espagram/TestBrain.m b/Espagram/TestBrain.m deleted file mode 100644 index 93466f0..0000000 --- a/Espagram/TestBrain.m +++ /dev/null @@ -1,34 +0,0 @@ -// -// TestBrain.m -// Espagram -// -// Created by Abel Fokkinga on 10/20/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import "TestBrain.h" - -@interface TestBrain() - -@property (nonatomic, strong) NSDictionary *testSet; - -@end - -@implementation TestBrain - -@synthesize testSet = _testSet; - - -- (NSArray *) testConjugation:(TestableConjugation *) conjugation { -return nil; -} - -- (int) checkAnswer:(NSString *)answer forConjugation:(TestableConjugation *) conjugation { - return true; -} - - - - - -@end diff --git a/Espagram/TestableVerb.h b/Espagram/TestableVerb.h new file mode 100644 index 0000000..65b8503 --- /dev/null +++ b/Espagram/TestableVerb.h @@ -0,0 +1,18 @@ +// +// TestableVerb.h +// Espagram +// +// Created by Abel Fokkinga on 11/15/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import +#import "Verb.h" + +@interface TestableVerb : NSObject + +@property (nonatomic, strong) Verb * verb; +@property (nonatomic, strong) NSString * person; +@property BOOL failed; + +@end diff --git a/Espagram/TestableVerb.m b/Espagram/TestableVerb.m new file mode 100644 index 0000000..320cb9a --- /dev/null +++ b/Espagram/TestableVerb.m @@ -0,0 +1,18 @@ +// +// TestableVerb.m +// Espagram +// +// Created by Abel Fokkinga on 11/15/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import "TestableVerb.h" + +@implementation TestableVerb + +@synthesize verb = _verb; +@synthesize person = _person; +@synthesize failed = _failed; + + +@end diff --git a/Espagram/Verb+Create.h b/Espagram/Verb+Create.h new file mode 100644 index 0000000..16b7d00 --- /dev/null +++ b/Espagram/Verb+Create.h @@ -0,0 +1,16 @@ +// +// Verb+Create.h +// Espagram +// +// Created by Abel Fokkinga on 11/16/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import "Verb.h" +#import "Lesson.h" + +@interface Verb (Create) + ++ (void) addVerb:(NSString *)newVerb andMeaning:(NSString *)meaning toLesson:(Lesson *)lesson; + +@end diff --git a/Espagram/Verb+Create.m b/Espagram/Verb+Create.m new file mode 100644 index 0000000..ac8aeb8 --- /dev/null +++ b/Espagram/Verb+Create.m @@ -0,0 +1,61 @@ +// +// Verb+Create.m +// Espagram +// +// Created by Abel Fokkinga on 11/16/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import "Verb+Create.h" + + +@implementation Verb (Create) + ++ (void) addVerb:(NSString *)newVerb andMeaning:(NSString *)meaning toLesson:(Lesson *)lesson +{ + Verb * verb = [NSEntityDescription insertNewObjectForEntityForName:@"Verb" inManagedObjectContext:[lesson managedObjectContext]]; + + // Check first if the lessons already contains this verb + for ( Verb * v in lesson.verbs) { + if ( [newVerb isEqualToString:v.verb]) { + if (meaning == nil) + return; + else if ([meaning isEqualToString:v.meaning]) + return; + } + } + + if ( [lesson.conjugator isEqualToString:@"Spanish"]) { + if ( newVerb.length >= 2 ) { + NSString *verbExit = [newVerb substringFromIndex:newVerb.length - 2]; + if ( ![verbExit isEqualToString:@"ar"] && + ![verbExit isEqualToString:@"er"] && + ![verbExit isEqualToString:@"ir"] && + ![verbExit isEqualToString:@"ír"] && + ![verbExit isEqualToString:@"se"] ) { + // Not an existing Spanish verb + return; + } + if ( [verbExit isEqualToString:@"se"] && newVerb.length >= 4 ) { + verbExit = [[newVerb substringFromIndex:newVerb.length - 4] substringToIndex:2]; + if ( ![verbExit isEqualToString:@"ar"] && + ![verbExit isEqualToString:@"er"] && + ![verbExit isEqualToString:@"ir"] && + ![verbExit isEqualToString:@"ír"] ) { + // Not an existing Spanish verb + return; + } + } + } else { + // Verb should be longer than 2 characters + return; + } + } + NSLog(@"Adding word %@", newVerb); + verb.verb = newVerb; + verb.meaning = meaning; + [lesson addVerbsObject:verb]; + [[lesson managedObjectContext] save:nil]; +}; + +@end diff --git a/Espagram/Verb.h b/Espagram/Verb.h new file mode 100644 index 0000000..70c207d --- /dev/null +++ b/Espagram/Verb.h @@ -0,0 +1,20 @@ +// +// Verb.h +// Espagram +// +// Created by Abel Fokkinga on 11/13/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import +#import + +@class Lesson; + +@interface Verb : NSManagedObject + +@property (nonatomic, retain) NSString * meaning; +@property (nonatomic, retain) NSString * verb; +@property (nonatomic, retain) Lesson *lesson; + +@end diff --git a/Espagram/Verb.m b/Espagram/Verb.m new file mode 100644 index 0000000..e5e3cae --- /dev/null +++ b/Espagram/Verb.m @@ -0,0 +1,19 @@ +// +// Verb.m +// Espagram +// +// Created by Abel Fokkinga on 11/13/12. +// Copyright (c) 2012 Abel Fokkinga. All rights reserved. +// + +#import "Verb.h" +#import "Lesson.h" + + +@implementation Verb + +@dynamic meaning; +@dynamic verb; +@dynamic lesson; + +@end diff --git a/Espagram/Verbs.h b/Espagram/Verbs.h deleted file mode 100644 index b091c6d..0000000 --- a/Espagram/Verbs.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// Verbs.h -// Espagram -// -// Created by Abel Fokkinga on 8/29/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import -#import - -@class ConjugatedTense; - -@interface Verbs : NSManagedObject - -@property (nonatomic, retain) NSString * verb; -@property (nonatomic, retain) NSString * language; -@property (nonatomic, retain) NSString * translation; -@property (nonatomic, retain) NSString * root; -@property (nonatomic, retain) ConjugatedTense *conjugatedTenses; - -@end diff --git a/Espagram/Verbs.m b/Espagram/Verbs.m deleted file mode 100644 index 20399bd..0000000 --- a/Espagram/Verbs.m +++ /dev/null @@ -1,21 +0,0 @@ -// -// Verbs.m -// Espagram -// -// Created by Abel Fokkinga on 8/29/12. -// Copyright (c) 2012 Abel Fokkinga. All rights reserved. -// - -#import "Verbs.h" -#import "ConjugatedTense.h" - - -@implementation Verbs - -@dynamic verb; -@dynamic language; -@dynamic translation; -@dynamic root; -@dynamic conjugatedTenses; - -@end diff --git a/Espagram/en.lproj/Localizable.strings b/Espagram/en.lproj/Localizable.strings new file mode 100644 index 0000000..8cbc407 Binary files /dev/null and b/Espagram/en.lproj/Localizable.strings differ diff --git a/Espagram/en.lproj/MainStoryboard.storyboard b/Espagram/en.lproj/MainStoryboard.storyboard index 33c0989..ca4ec0a 100644 --- a/Espagram/en.lproj/MainStoryboard.storyboard +++ b/Espagram/en.lproj/MainStoryboard.storyboard @@ -8,57 +8,79 @@ - + - + - + - + - - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + @@ -67,77 +89,92 @@ - + - - + + - + - - - + + - + - - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + @@ -146,81 +183,78 @@ - + - - + + - + - - - + + - + - - + - - + + - + - + + + + + + + + + + + @@ -229,83 +263,22 @@ - + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -318,57 +291,470 @@ - + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + + + + + + + - + - - - - - - - + - + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -408,8 +794,97 @@ + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -430,25 +905,9 @@ - - - - - - - - - - - - - - - - - - - + + + diff --git a/Espagram/es.lproj/Localizable.strings b/Espagram/es.lproj/Localizable.strings new file mode 100644 index 0000000..7e9e852 Binary files /dev/null and b/Espagram/es.lproj/Localizable.strings differ diff --git a/Espagram/nl.lproj/Localizable.strings b/Espagram/nl.lproj/Localizable.strings new file mode 100644 index 0000000..626a592 --- /dev/null +++ b/Espagram/nl.lproj/Localizable.strings @@ -0,0 +1,85 @@ +/* + Localizable.strings + Espagram + + Created by Abel Fokkinga on 11/18/12. + Copyright (c) 2012 Abel Fokkinga. All rights reserved. +*/ + +/* About button text */ +"About button" = "Info"; + +/* Lessons title */ +"Lessons title" = "Lessen"; + +/* Add button for adding a new lesson */ +"Add Lesson" = "Opslaan"; + +/* "Cancel button when adding a new lesson" */ +"Cancel Lesson" = "Annuleer"; + +/* Add button when adding a verb to a lesson */ +"Add Verb" = "Toevoegen"; + +/* Cancel button to cancel adding a verb to a lesson */ +"Cancel Verb" = "Annuleer"; + +/* Lesson description when adding a new lesson */ +"Description" = "Omschrijving"; + +/* Lesson title when adding a new lesson */ +"Lesson title" = "Titel"; + +/* Adding the meaning of a new verb being added to a lesson */ +"Meaning" = "Betekenis"; + +/* Adding a new verb to a lesson */ +"New verb" = "Nieuw werkwoord"; + +/* Next button in the testing screen to continue to the next verb */ +"Next" = "Volgende"; + +/* Simple present tense description */ +"TENSE_SIMPLE_PRESENT" = "Tegenwoordige tijd"; + +/* Simple past tense description */ +"TENSE_SIMPLE_PAST" = "Verleden tijd"; + +/* Imperfect tense description */ +"TENSE_IMPERFECT" = "Onvoltooid verleden tijd"; + +/* Future tense description */ +"TENSE_FUTURE" = "Toekomende tijd"; + +/* Future perfect tense description */ +"TENSE_PRESENT_PERFECT" = "Voltooid tegenwoordige tijd"; + +/* Past perfect tense description */ +"TENSE_PAST_PERFECT" = "Voltooid verleden tijd"; + +/* Future perfect tense description */ +"TENSE_FUTURE_PERFECT" = "Voltooid tegenwoordige toekomende tijd"; + +/* Condicional tense description */ +"TENSE_CONDICIONAL" = "Onvoltooid verleden toekomende tijd"; + +/* Condicional tense description */ +"TENSE_CONDICIONAL_PERFECT" = "Voltooid verleden toekomende tijd"; + +/* Gerund tense description */ +"TENSE_GERUND" = "Gerundium"; + +/* Imperative tense description */ +"TENSE_IMPERATIVE" = "Gebiedende wijs"; + +/* Present subjunctive tense description */ +"TENSE_PRESENT_SUBJUNCTIVE" = "Aanvoegende wijs"; + +/* Present subjunctive tense description */ +"TENSE_PRESENT_PERFECT_SUBJUNCTIVE" = "Voltooid aanvoegende wijs"; + +/* Present perfect subjunctive tense description */ +"TENSE_IMPERFECT_SUBJUNCTIVE" = "Onvoltooid aanvoegende wijs"; + +/* Past perfect subjunctive tense description */ +"TENSE_PAST_PERFECT_SUBJUNCTIVE" = "Voltooid verleden aanvoegende wijs"; \ No newline at end of file diff --git a/Espagram/pt.lproj/Localizable.strings b/Espagram/pt.lproj/Localizable.strings new file mode 100644 index 0000000..c19d151 Binary files /dev/null and b/Espagram/pt.lproj/Localizable.strings differ diff --git a/iPhoneIcon_Big.png b/iPhoneIcon_Big.png new file mode 100644 index 0000000..e3da532 Binary files /dev/null and b/iPhoneIcon_Big.png differ diff --git a/iPhoneIcon_Small.png b/iPhoneIcon_Small.png new file mode 100644 index 0000000..d4fcaf1 Binary files /dev/null and b/iPhoneIcon_Small.png differ