Starting from:

$29

Homework 2 HealthApp that displays happy quotations


School of Electrical Engineering and Computer Science

CptS 479 Mobile Application Development
Homework 2

General Instructions: Put the entire app directory into one zip file and submit as an attachment
under Content Homework 2 for this course on Blackboard Learn by the above deadline. Note
that you may submit multiple times, but only the most recent entry submitted before the above
deadline will be graded.
For this homework you will implement a different version of the HealthApp that displays happy
quotations and also allows you to enter new quotations. See screen shots below. Specifically,
1. You can create a new project or modify your HW1 project.
2. Create a new swift file named “Quotation.swift” which should contain the definition of the
Quotation class. This class should have two properties: a string to hold the quote and an
optional string to hold the author. The init method should require a string for the quote, but
the author string is optional and should be set to nil if not provided.
3. In the main view of the Storyboard, add a Label at the top of the view with the app’s name
“Health App”. Below that add a Label with “Larry’s Happy Quotes” with your first name
in place of “Larry”. These labels should be centered horizontally and constrained to be
appropriately spaced at the top of the view.
4. Below the labels should be two text fields. The first text field should have the label
“Quote:” to the left and fill the rest of the view horizontally. The second text field should
have the label “Author:” to the left and fill the rest of the view horizontally. Set both text
field’s delegate to the ViewController and define the textFieldShouldReturn delegate
method so that the keyboard disappears when you tap Return on the keyboard.
5. Centered below the text fields should be a button titled “Add”. When you tap the Add
button, if the Quote text field is non-empty, then you should create a new instance of the
Quotation class with that quote, which should be added to the end of your current list of
quotations. If the author is provided, then that should be added to the Quotation instance.
If the Quote text field is empty, then the Add button should have no effect. If a Quotation
is added, then the two text fields should be cleared automatically. Anytime the Add button
is tapped, if the keyboard is present, it should be removed. This can be done by executing
“self.view.endEditing(true)”. Quotations added while the app is running do not need to
persist when the app is terminated.
2
6. This app will not display any images. Instead, a Quotation Label should be centered
vertically in the view and fill the whole view horizontally. Set the “Lines” attribute of the
label to 4, and set the “Alignment” attribute to Center.
7. As in HW1, centered at the bottom of the view, should be a Button called “Next”. Tapping
the Next button cycles through all the quotations, including your initial three and any added
quotations. Tapping Next on the last quotation should cycle back to the first.
8. Initialize your app with at least three quotations. Quotations should be displayed in the
Quotation label surrounded by double quotes. If the author is provided, then it should be
displayed after the quote. If no author is provided, then “Anonymous” (without the quotes)
should be displayed after the quote.
9. Test your app using the iPhone 11 simulator, which is the same simulator we will use to
grade your app.
10. Be sure that auto layout constraints are set so that the view elements are appropriately
displayed with no overlap or trimming regardless of device orientation.
3
Storyboard:
Simulator:

More products