Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please do all questions!!! iPhone Programming - Spring 2019 Assignment 1- Due: Wednesday, Feb. 20 In this assignment you will explore Objective-C, the Foundation Framework

please do all questions!!!

image text in transcribedimage text in transcribed

iPhone Programming - Spring 2019 Assignment 1- Due: Wednesday, Feb. 20 In this assignment you will explore Objective-C, the Foundation Framework and Xcode. In brief, you will create a program that keeps track of grade book for a teacher. Firs, n Xcode, you will be creating a New Project. Choose "File:New Project" and then from the top panel choose to create a new "macOS' (nol iOS) "Command Line Tool". Afier these choices have been made, on the nexl screen create a name for organization namenyu.elu' will suffice), and for the language select "Objective-C". This should provide a good template for your project. Note that all of your code will go within the main.m file In this homework, you will create a new NSMutableDictionary Object which we might call "course" .The Key for the dictionary is the name of the student, and its Value is a class (Student _Info) which includes 1) a string which is the address of the student; 2) a loating point number which is the student's Midterm Score: 3) a Floating point number which is the Final Score: 4) and three Integers which are the Homework Scores. Thus, a possible data sct might look something like this: Student_Info Key (Name) Address New York River Heights Cabot Cove New York St. M Mcad Midterm 99.0 85.5 88.0 79.9 99.0 Final 100.0 80.5 90.5 75.0 90.0 Homework 1 10 0 Homework 2 10 0 10 Homework 3 Joan Watson Nancy Drew Jessica Fletcher Nora Charles Miss Marple 10 ary 0 10 10 There are many, many methods for Dictionaries which are given to you in the Foundation Framework. Let's look at one of them. The following is the official Apple definition of setObject: (void) seLObject: (id) anObject forKey: (d) aKey - In our book, "Programming in Objective-C" by Stephen Kochan, the author gives the following example of this method glossary setobject: e"A class defined so other elasses can inherit from it" forxey:"abstract class" In this case,glossary is a Mutable Dictionary which has already been defined and bolh the Key (forkey) and the Value (setobject) are NSStrings. However, note that neither the Key nor the Value have to be strings, although that is what is most often demonstrated. They can be any kind of object. So, in our homework, although the Key is a string, the Value should be a new kind of ohject (maybe call it "Student_Info") that consists of a string, two floaling point numbers, and three integers Therefore, part o the problem will be to create a new class, Student_Info, which will be defined in separate Interface and Implementation Files (p:rhaps Student_Info.h and Stucent_Info.. To reate these new classes in Xcode, chocise "File NewFile* and then choose "macOS" on the top panel and "Cocoa Class" on the bottom. There are at least five other methods you should wrile: 1. You should create a method "Print_object" which prints out the Student_Info class in some kind of pretty format using NSLog (which, conceivably might be part of the Student_Info class) 2. You should creatc a mcthod "Add Student" which adds a new itcm to the dictionary given Name and Address. It should initilizc all thc other variables i.e., the scores). The method should retu a Boolean value which indicates whether a student has been successfully added or not. (A duplicate Key Name should cause it to be rejected). Also note that you should use "lazy instantiation' on the dictionary itself the first added item should cause the ditonary to be created 3. You should write a method called 'Add_Test" that given a Key/Name, an integer represeninhe test score, and a string which is either midterm' or 'final' will sct the sclected test variable in the Student_Info objcct. Thc method should return a Boolcan value whiclh indicates whether the test score has been successfully added or not. 4. You should write a method "Add Hthat given a Key Name, and an integer representing the llomework score, will set the selected Homework variable in the scudent_Info objel. The melhod should rlurn a Boolean value which indicates whether the Homework score has bcen succcssfully added or not 5. You should write a method "Student Average" which computes the student's semester average based upon 30% Midterm, 40% Final and 30% IIomework. It should print out this average. The method should return a Boolean value which indicates whether all the students scores were scl or nol In your main function, you should do (at lcast) the following opcrations. It scems logical that you might clect to makc many of them into melhcls, Ihul yuu are not required to do s: 1. Add some entries by hard-coding some calls to your 'Add SLLdeaL method 2. Add some lest and homework scores to a few sludenlsby cling "Add lest" and "Adid H 3. Print out the dictionary by enumerating it. (Note that you will have to print the key'name for each record directly, but that the value portion can be printed by "Print objcet") 4. Delete a few entries. (You might want to write a method to this, too!) 5. Print out th dictionary again 6. Add some more students and scorcs 7. Prinl out dionary yel again In addition to the material in your texthook, don't fore that Apple provides you with a ch set of reference material. The iPhone Developers website has lots of information on Objective-C, but much of that material is also available from within Xcode. l'or example, you can simply choosc "Ilclp: Documentation" and typc "NSMutablcDictionary" in the scarch box. and a wcalth of information is availablc to you including a pdl file deseribing Ihe whol: class. (D'gel lo look a the supT class "NSDiclionary") iPhone Programming - Spring 2019 Assignment 1- Due: Wednesday, Feb. 20 In this assignment you will explore Objective-C, the Foundation Framework and Xcode. In brief, you will create a program that keeps track of grade book for a teacher. Firs, n Xcode, you will be creating a New Project. Choose "File:New Project" and then from the top panel choose to create a new "macOS' (nol iOS) "Command Line Tool". Afier these choices have been made, on the nexl screen create a name for organization namenyu.elu' will suffice), and for the language select "Objective-C". This should provide a good template for your project. Note that all of your code will go within the main.m file In this homework, you will create a new NSMutableDictionary Object which we might call "course" .The Key for the dictionary is the name of the student, and its Value is a class (Student _Info) which includes 1) a string which is the address of the student; 2) a loating point number which is the student's Midterm Score: 3) a Floating point number which is the Final Score: 4) and three Integers which are the Homework Scores. Thus, a possible data sct might look something like this: Student_Info Key (Name) Address New York River Heights Cabot Cove New York St. M Mcad Midterm 99.0 85.5 88.0 79.9 99.0 Final 100.0 80.5 90.5 75.0 90.0 Homework 1 10 0 Homework 2 10 0 10 Homework 3 Joan Watson Nancy Drew Jessica Fletcher Nora Charles Miss Marple 10 ary 0 10 10 There are many, many methods for Dictionaries which are given to you in the Foundation Framework. Let's look at one of them. The following is the official Apple definition of setObject: (void) seLObject: (id) anObject forKey: (d) aKey - In our book, "Programming in Objective-C" by Stephen Kochan, the author gives the following example of this method glossary setobject: e"A class defined so other elasses can inherit from it" forxey:"abstract class" In this case,glossary is a Mutable Dictionary which has already been defined and bolh the Key (forkey) and the Value (setobject) are NSStrings. However, note that neither the Key nor the Value have to be strings, although that is what is most often demonstrated. They can be any kind of object. So, in our homework, although the Key is a string, the Value should be a new kind of ohject (maybe call it "Student_Info") that consists of a string, two floaling point numbers, and three integers Therefore, part o the problem will be to create a new class, Student_Info, which will be defined in separate Interface and Implementation Files (p:rhaps Student_Info.h and Stucent_Info.. To reate these new classes in Xcode, chocise "File NewFile* and then choose "macOS" on the top panel and "Cocoa Class" on the bottom. There are at least five other methods you should wrile: 1. You should create a method "Print_object" which prints out the Student_Info class in some kind of pretty format using NSLog (which, conceivably might be part of the Student_Info class) 2. You should creatc a mcthod "Add Student" which adds a new itcm to the dictionary given Name and Address. It should initilizc all thc other variables i.e., the scores). The method should retu a Boolean value which indicates whether a student has been successfully added or not. (A duplicate Key Name should cause it to be rejected). Also note that you should use "lazy instantiation' on the dictionary itself the first added item should cause the ditonary to be created 3. You should write a method called 'Add_Test" that given a Key/Name, an integer represeninhe test score, and a string which is either midterm' or 'final' will sct the sclected test variable in the Student_Info objcct. Thc method should return a Boolcan value whiclh indicates whether the test score has been successfully added or not. 4. You should write a method "Add Hthat given a Key Name, and an integer representing the llomework score, will set the selected Homework variable in the scudent_Info objel. The melhod should rlurn a Boolean value which indicates whether the Homework score has bcen succcssfully added or not 5. You should write a method "Student Average" which computes the student's semester average based upon 30% Midterm, 40% Final and 30% IIomework. It should print out this average. The method should return a Boolean value which indicates whether all the students scores were scl or nol In your main function, you should do (at lcast) the following opcrations. It scems logical that you might clect to makc many of them into melhcls, Ihul yuu are not required to do s: 1. Add some entries by hard-coding some calls to your 'Add SLLdeaL method 2. Add some lest and homework scores to a few sludenlsby cling "Add lest" and "Adid H 3. Print out the dictionary by enumerating it. (Note that you will have to print the key'name for each record directly, but that the value portion can be printed by "Print objcet") 4. Delete a few entries. (You might want to write a method to this, too!) 5. Print out th dictionary again 6. Add some more students and scorcs 7. Prinl out dionary yel again In addition to the material in your texthook, don't fore that Apple provides you with a ch set of reference material. The iPhone Developers website has lots of information on Objective-C, but much of that material is also available from within Xcode. l'or example, you can simply choosc "Ilclp: Documentation" and typc "NSMutablcDictionary" in the scarch box. and a wcalth of information is availablc to you including a pdl file deseribing Ihe whol: class. (D'gel lo look a the supT class "NSDiclionary")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions

Question

Describe three major steps used in the scientific method.

Answered: 1 week ago

Question

What can Chandra do to correct her mistake?

Answered: 1 week ago