Question: swift ios app! Create your first app completely from scratch by yourself. It is similar enough to Lab 1 that you should be able to
swift ios app!
Create your first app completely from scratch by yourself. It is similar enough to Lab 1 that you should be able to leverage what you have learned, but sufficiently different to ensure you understand coding concepts learned to date. As this starts from scratch, you need to begin with Create a new Xcode Project from the splash screen. Any shortcuts will be submitted to the university committee on academic integrity as a violation. First, familiarize yourself with the game of Set as described in: https://en.wikipedia.org/wiki/Set_(game) Requirements: A) Implement a solo game of Set (i.e. one player) using 81 select cards per the rules of Set. B) Have room on the screen for at least 24 Set cards. All cards are always face up in Set. This should not be in your model as it is UI oriented. C) Deal 12 cards to start. They can be anywhere on the screen, but should not overlap. For example, they can be scattered around the screen and not aligned such as at the top, bottom, etc. D) Allow the user to select cards to try and match a set by touching the cards. It is up to you how you want to show the selection in your UI. Support deselection as well when only 1 or 2 (not 3) cards are currently selected. E) After 3 cards have been selected, indicate whether those 3 cards are a match or not. Be clear so there is no misunderstanding. See Hint 4 below. F) When a card is selected and there are already 3 non-matching Set cards selected, deselect the 3 and select the newly chosen card. G) Alternatively, when a card is selected and there are 3 matching Set cards selected, replace those 3 matching Set cards with new ones from the deck of 81 Set cards (this functionality is to be in the model) H) Create a Deal 3 More Cards button per the rules of Set. If 3 cards are selected and match when this button is hit, replace the 3 cards with new ones from the remainder of the deck of 81 Set cards. Note, this functionality is to be in the model. Please also note there is always room to replace 3 matched cards in the UI. I) If cards dont match and the Deal 3 More Cards is selected, add 3 cards to the game. Disable the Deal 3 More Cards button if you run out of room on the screen to add cards (ie. 24 as stated in B) above). Running out of room is UI oriented so this functionality should not be in your model. J) If the deck becomes empty during this process, disable the Deal 3 More Cards button. This functionality is to be in the model. K) Instead of drawing the Set cards in the classic form (we may do that in the future), use these three exact Unicode characters with the font systemFont and use attributes in NSAttributedString to draw them appropriately (i.e. colors and shading). That way, your cards can just be UIButtons. See Hints below for suggestions on how to the show various Set cards. Use whatever colors you want; you dont have to use the standard Set colors. L) Use a method that takes a closure as an argument as a meaningful part of your solution. You cannot use one shown in a lecture. M) Use an enum as a meaningful part of your solution. N) Add a sensible extension to some data structure as a meaningful part of your solution. Do not use one shown in a lecture. O) Focus on a well laid out UI in Portrait on any iPhone 7 or newer. This means you cannot use a simple Autolayout with stack views. P) Have a new game button as we did in Concentration showing the score in the UI. Score the game with 3 for a match, -4 for a mismatch, and -1 for a deselection. Hints 1. Use the same UI layout as in Concentration adding stack views. Starting the game with 12 where 24 is the total, some of the buttons initially will not show a card. Late in the game, there will be matched cards that cant be replaced. Treat these instances like a matched and removed card from Concentration. Stated another way, the button is there but not visible. 2. Consider a couple of excellent methods in Array called index(of:) and contains(). They only work for Arrays of things that implement the Equatable protocol (like Int and String). If you have a data type of your own, make sure it implements Equatable. 3. We used mutable Cards in Concentration to track face up and down. It would be better architecturally to use constants (i.e. let) for this game to make the code cleaner. This way, you could identify the selected (or already matched cards) with a Bool in your Set Card data structure. Note that you will want to implement Hint 2 to implement this 3rd hint. 4. You can show selection using the UIButtons background color. Alternatively, you could put a border around the UIButton with the following code that includes rounded corners: button.layer.borderWidth = 3.0 button.layer.borderColor = UIColor.blue.cgColor button.layer.cornerRadius = 8.0 5. If you want a character in an NSAttributedString to be filled in, specify an NSAttributedStringKey.strokeWidth which is a negative number. 6. For the striped look of a Set card, use an NSAttributedStringKey.foregroundColor of about 15% alpha created with the UIColor method withAlphaComponent. A 100% alpha foregroundColor can be used for the filled look and a positive strokeWidth for the outline look. A third NSAttributedStringKey to consider for this lab is NSAttributedSgtringKey.strokeColor. 7. Not that a UIButtons title and its attributedTitle can both be set separately (attributedTitle takes precedence if set). If you dont want a title, set both to nil. 8. Colors are not to be stored in the model as they are UI oriented. As a result, NSAttributedStringKeys like foregroundColor should not be in the model. This way, should we drop using attributed strings in the following weeks, you wont have to change your model at all. Think through how to make your Model have the correct API to communicate what is going on in the game. Do not make any assumptions on how the game is being presented to the user, though. 9. A Set game has a list of cards that are being played, it has some selected cards, it knows whether the currently selected cards are a match (or not), it has a deck of cards from which it is dealing, and it keeps track of which cards have been matched. Thats about it. Make sure your models API presents these concepts cleanly. The only actual functionality your Model has is selecting cards to try to match them and dealing 3 new cards as these are the fundamental concepts of the Set game. Preventing the addition of 3 more cards because your UI is full is UI related and should not be in your model. 10. Test the game as the deck runs out. Successfully matched cards can no longer be replaced with new cards, but cant appear in the UI any longer. For this reason, your Models API will have to reveal which cards have been successfully matched. 11. Remember, your Model doesnt note successfully matched cards until the next card selection or the Deal 3 More Cards button is pressed. 12. Your model should be less than 100 lines (excluding comments and curly braces); in fact, it can be accomplished with far less. Your ViewController is probably of similar scope. If you need much more than 200 lines of code, you have taken a wrong turn somewhere.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
