欢迎光临散文网 会员登陆 & 注册

iOS移动应用程序开发 | 第三讲-集合与流程控制:Going Loopy...

2023-01-09 20:10 作者:陈鹏宇老师  | 我要投稿


01:05:44


第三次作业

作业一:完成Playgrounds App《学习编程2》1-3章


作业二:完成下面的练习题

1. Consider the following simple game. The game starts at level 1, and finishes at level 10. We've partially written a repeat-while loop to run the game. Fill in the two gaps.


2. The Chef, who is pretty grumpy at the best of times, wants to sort the restaurant's pizzas alphabetically using Swift (after all, it's in the name).

They're facing some issues, though. Can you help the chef sort their pizzas?

Consider the chef's list of pizzas, which they've stored as independently created String variables, and come up with:

(i) A better way to represent the list of pizzas, using one of the collection types that you've learned about.

(ii) A way to operate on your new pizza collection to sort the pizzas into alphabetical order and print them.


3. A Swift program is all scrambled up on the next page. Can you rearrange the code snippets to make a working program that produces the output below? The code uses concepts we've looked at in detail, as well as a few that we haven’t.



4. Your job is to take lines of code from the pool and place them into the blank lines in the Playground. You may not use the same line more than once, and you won’t need to use all the lines. Your goal is to make the code that will generate the output shown below, given the starting variables:



5. Each of the Swift code snippets on this page represents a complete Playground. Your job is to play Swift compiler, and determine whether each of these will run or not. If they will not compile, how would you fix them?


iOS移动应用程序开发 | 第三讲-集合与流程控制:Going Loopy...的评论 (共 条)

分享到微博请遵守国家法律