From 3ddb1ebc4094aecd1da6da368930cffe2b7ba757 Mon Sep 17 00:00:00 2001 From: Sanskar <> Date: Sat, 29 Jan 2022 13:42:22 +0530 Subject: [PATCH] assignmnet1 added --- Assignment_1/.gitignore | 28 ++ .../Assignment_1.xcodeproj/project.pbxproj | 309 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + Assignment_1/Assignment_1/ImportedItem.swift | 41 +++ Assignment_1/Assignment_1/Items.swift | 32 ++ .../Assignment_1/ManufacturedItem.swift | 32 ++ Assignment_1/Assignment_1/RawItem.swift | 32 ++ Assignment_1/Assignment_1/Tax.swift | 14 + Assignment_1/Assignment_1/main.swift | 182 +++++++++++ 10 files changed, 685 insertions(+) create mode 100644 Assignment_1/.gitignore create mode 100644 Assignment_1/Assignment_1.xcodeproj/project.pbxproj create mode 100644 Assignment_1/Assignment_1.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Assignment_1/Assignment_1.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Assignment_1/Assignment_1/ImportedItem.swift create mode 100644 Assignment_1/Assignment_1/Items.swift create mode 100644 Assignment_1/Assignment_1/ManufacturedItem.swift create mode 100644 Assignment_1/Assignment_1/RawItem.swift create mode 100644 Assignment_1/Assignment_1/Tax.swift create mode 100644 Assignment_1/Assignment_1/main.swift diff --git a/Assignment_1/.gitignore b/Assignment_1/.gitignore new file mode 100644 index 0000000..cc0c13c --- /dev/null +++ b/Assignment_1/.gitignore @@ -0,0 +1,28 @@ + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +#*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +*.framework + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control +# +Pods diff --git a/Assignment_1/Assignment_1.xcodeproj/project.pbxproj b/Assignment_1/Assignment_1.xcodeproj/project.pbxproj new file mode 100644 index 0000000..87cf875 --- /dev/null +++ b/Assignment_1/Assignment_1.xcodeproj/project.pbxproj @@ -0,0 +1,309 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 55; + objects = { + +/* Begin PBXBuildFile section */ + CB249575279F108B00309624 /* Tax.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB249574279F108B00309624 /* Tax.swift */; }; + CB3077FF2795368000928221 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB3077FE2795368000928221 /* main.swift */; }; + CB451FA9279FE8FF00213496 /* Items.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB451FA8279FE8FF00213496 /* Items.swift */; }; + CB8965FB279FE0BC001BAC6C /* ManufacturedItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB8965FA279FE0BC001BAC6C /* ManufacturedItem.swift */; }; + CB8965FD279FE0D8001BAC6C /* RawItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB8965FC279FE0D8001BAC6C /* RawItem.swift */; }; + CB8965FF279FE0E7001BAC6C /* ImportedItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB8965FE279FE0E7001BAC6C /* ImportedItem.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + CB3077F92795368000928221 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + CB22823D2799C84A00115B8C /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitignore; sourceTree = ""; }; + CB249574279F108B00309624 /* Tax.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tax.swift; sourceTree = ""; }; + CB3077FB2795368000928221 /* Assignment_1 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Assignment_1; sourceTree = BUILT_PRODUCTS_DIR; }; + CB3077FE2795368000928221 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + CB451FA8279FE8FF00213496 /* Items.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Items.swift; sourceTree = ""; }; + CB8965FA279FE0BC001BAC6C /* ManufacturedItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManufacturedItem.swift; sourceTree = ""; }; + CB8965FC279FE0D8001BAC6C /* RawItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RawItem.swift; sourceTree = ""; }; + CB8965FE279FE0E7001BAC6C /* ImportedItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImportedItem.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + CB3077F82795368000928221 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + CB3077F22795368000928221 = { + isa = PBXGroup; + children = ( + CB22823D2799C84A00115B8C /* .gitignore */, + CB3077FD2795368000928221 /* Assignment_1 */, + CB3077FC2795368000928221 /* Products */, + ); + sourceTree = ""; + }; + CB3077FC2795368000928221 /* Products */ = { + isa = PBXGroup; + children = ( + CB3077FB2795368000928221 /* Assignment_1 */, + ); + name = Products; + sourceTree = ""; + }; + CB3077FD2795368000928221 /* Assignment_1 */ = { + isa = PBXGroup; + children = ( + CB3077FE2795368000928221 /* main.swift */, + CB451FA8279FE8FF00213496 /* Items.swift */, + CB249574279F108B00309624 /* Tax.swift */, + CB8965FA279FE0BC001BAC6C /* ManufacturedItem.swift */, + CB8965FC279FE0D8001BAC6C /* RawItem.swift */, + CB8965FE279FE0E7001BAC6C /* ImportedItem.swift */, + ); + path = Assignment_1; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + CB3077FA2795368000928221 /* Assignment_1 */ = { + isa = PBXNativeTarget; + buildConfigurationList = CB3078022795368000928221 /* Build configuration list for PBXNativeTarget "Assignment_1" */; + buildPhases = ( + CB3077F72795368000928221 /* Sources */, + CB3077F82795368000928221 /* Frameworks */, + CB3077F92795368000928221 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Assignment_1; + productName = Assignment_1; + productReference = CB3077FB2795368000928221 /* Assignment_1 */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + CB3077F32795368000928221 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1320; + LastUpgradeCheck = 1320; + TargetAttributes = { + CB3077FA2795368000928221 = { + CreatedOnToolsVersion = 13.2.1; + }; + }; + }; + buildConfigurationList = CB3077F62795368000928221 /* Build configuration list for PBXProject "Assignment_1" */; + compatibilityVersion = "Xcode 13.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = CB3077F22795368000928221; + productRefGroup = CB3077FC2795368000928221 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + CB3077FA2795368000928221 /* Assignment_1 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + CB3077F72795368000928221 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CB8965FF279FE0E7001BAC6C /* ImportedItem.swift in Sources */, + CB249575279F108B00309624 /* Tax.swift in Sources */, + CB8965FD279FE0D8001BAC6C /* RawItem.swift in Sources */, + CB3077FF2795368000928221 /* main.swift in Sources */, + CB451FA9279FE8FF00213496 /* Items.swift in Sources */, + CB8965FB279FE0BC001BAC6C /* ManufacturedItem.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + CB3078002795368000928221 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 11.5; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + CB3078012795368000928221 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 11.5; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + CB3078032795368000928221 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + CB3078042795368000928221 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + CB3077F62795368000928221 /* Build configuration list for PBXProject "Assignment_1" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CB3078002795368000928221 /* Debug */, + CB3078012795368000928221 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CB3078022795368000928221 /* Build configuration list for PBXNativeTarget "Assignment_1" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CB3078032795368000928221 /* Debug */, + CB3078042795368000928221 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = CB3077F32795368000928221 /* Project object */; +} diff --git a/Assignment_1/Assignment_1.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Assignment_1/Assignment_1.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Assignment_1/Assignment_1.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Assignment_1/Assignment_1.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Assignment_1/Assignment_1.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Assignment_1/Assignment_1.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Assignment_1/Assignment_1/ImportedItem.swift b/Assignment_1/Assignment_1/ImportedItem.swift new file mode 100644 index 0000000..86cccd7 --- /dev/null +++ b/Assignment_1/Assignment_1/ImportedItem.swift @@ -0,0 +1,41 @@ +// +// RawTax.swift +// Assignment_1 +// +// Created by Sanskar on 24/01/22. +// + +import Foundation + +class ImportedItem : Items +{ + override init(_ name:String,_ quantity:Int,_ price:Double) + { + super.init(name, quantity, price) + } + + override func calculateTax() -> Double + { + let finalCost : Double = (0.01 * price) + price + if( finalCost > 200) + { + return ((0.05 * finalCost) - price ) + } + else if( finalCost > 100) + { + return (finalCost + 10 - price) + } + return (finalCost + 5 - price ) + } + + override func print() + { + super.print() + Swift.print("Type : imported") + Swift.print("Tax : \(calculateTax())") + Swift.print("Total price : \(calculateTax() + self.price)") + + Swift.print() + Swift.print("-------------------------------------------------") + } +} diff --git a/Assignment_1/Assignment_1/Items.swift b/Assignment_1/Assignment_1/Items.swift new file mode 100644 index 0000000..68380d2 --- /dev/null +++ b/Assignment_1/Assignment_1/Items.swift @@ -0,0 +1,32 @@ +// +// items.swift +// Assignment_1 +// +// Created by Sanskar on 24/01/22. +// + +import Foundation + +class Items : Tax +{ + var name: String + var quantity: Int + var price: Double + + func calculateTax() -> Double { + return 0 + } + + func print() { + Swift.print("Name : \(self.name)") + Swift.print("Price : \(self.price)") + Swift.print("Quantity : \(self.quantity)") + } + + init(_ name: String, _ quantity: Int, _ price: Double) + { + self.name = name + self.quantity = quantity + self.price = price + } +} diff --git a/Assignment_1/Assignment_1/ManufacturedItem.swift b/Assignment_1/Assignment_1/ManufacturedItem.swift new file mode 100644 index 0000000..cd8f6b0 --- /dev/null +++ b/Assignment_1/Assignment_1/ManufacturedItem.swift @@ -0,0 +1,32 @@ +// +// RawTax.swift +// Assignment_1 +// +// Created by Sanskar on 24/01/22. +// + +import Foundation + +class ManufacturedItem : Items +{ + override init(_ name:String,_ quantity:Int,_ price:Double) + { + super.init(name, quantity, price) + } + + override func calculateTax() -> Double + { + return (0.125 * price + (0.02 * (price + (0.125 * price)))) + } + + override func print() + { + super.print() + Swift.print("Type : manufactured") + Swift.print("Tax : \(calculateTax())") + Swift.print("Total price : \(calculateTax() + self.price)") + + Swift.print() + Swift.print("-------------------------------------------------") + } +} diff --git a/Assignment_1/Assignment_1/RawItem.swift b/Assignment_1/Assignment_1/RawItem.swift new file mode 100644 index 0000000..b405ff2 --- /dev/null +++ b/Assignment_1/Assignment_1/RawItem.swift @@ -0,0 +1,32 @@ +// +// RawTax.swift +// Assignment_1 +// +// Created by Sanskar on 24/01/22. +// + +import Foundation + +class RawItem : Items +{ + override init(_ name:String,_ quantity:Int,_ price:Double) + { + super.init(name, quantity, price) + } + + override func calculateTax() -> Double + { + return (0.125 * price) + } + + override func print() + { + super.print() + Swift.print("Type : raw") + Swift.print("Tax : \(calculateTax())") + Swift.print("Total price : \(calculateTax() + self.price)") + + Swift.print() + Swift.print("-------------------------------------------------") + } +} diff --git a/Assignment_1/Assignment_1/Tax.swift b/Assignment_1/Assignment_1/Tax.swift new file mode 100644 index 0000000..37ff0bb --- /dev/null +++ b/Assignment_1/Assignment_1/Tax.swift @@ -0,0 +1,14 @@ +// +// Tax.swift +// Assignment_1 +// +// Created by Sanskar on 24/01/22. +// + +import Foundation + +protocol Tax +{ + func calculateTax() -> Double + func print() +} diff --git a/Assignment_1/Assignment_1/main.swift b/Assignment_1/Assignment_1/main.swift new file mode 100644 index 0000000..8bb65b9 --- /dev/null +++ b/Assignment_1/Assignment_1/main.swift @@ -0,0 +1,182 @@ + +// +// main.swift +// assignment1 +// +// Created by Sanskar on 11/01/22. +// +import Foundation + +var detailsOfAllItems = [Items & Tax]() //array of object to store details of all item + +func takeInput() -> () +{ + var name:String = "" + var quantity:Int = 1 + var price:Double? + var type:String? + + let wrongInput: String = "Invalid Input format" + + print("Enter the Input") + let value : String? = readLine() + + if(value!.isEmpty) + { + print(" \(wrongInput) : Please enter details ") + return + } + + if let inputValue = value // for having a input + { + let itemInputArray = inputValue.components(separatedBy: " ") //separating input string words by white spaces + + if(itemInputArray[0] != "-name") + { + print(" \(wrongInput) : First value should be -name ") + return + } + + if(itemInputArray.count == 1) // if after -name nothing present + { + print(wrongInput) + return + } + + var indexAfterName:Int = 0 + + if(itemInputArray[1].first == "-") // if second word start with - rather than name + { + print(" \(wrongInput) : Enter proper name ") + return + } + + for index in 2..