国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

iOS移動(dòng)應(yīng)用程序開發(fā) | 第四講-函數(shù)和枚舉:Reusing Code ...

2023-01-10 08:28 作者:陳鵬宇老師  | 我要投稿

?
01:23:07
?

第四次作業(yè)

作業(yè)一:完成Playgrounds App《學(xué)習(xí)編程2》第4、5章


作業(yè)二:完成下面的練習(xí)題

1. Write a billSplit function to help calculate how to evenly split a dining bill. The function should take parameters for the total cost of the meal (a Double), a tip percentage (an Int), and a number of diners (an Int). It should print how much each diner will need to pay.


2. Write a better version of the billSplit function to help calculate how to evenly split a dining bill. This time, the function should have sensible defaults for some of the values: 2 diners, 20% tip. It should still print how much each diner will need to pay.


3 (i) Create a new enumeration to represent movie genres. It should contain a handful of movie genres, of your choice Once you’ve created it, make a switch statement, and switch on a variable storing a genre (maybe call it favoriteGenre?). Print out a sassy comment for each genre.?

(ii) With that working, try creating a new enumeration that represents cocktails. For each cocktail, store a raw string value describing the cocktail. With that done, iterate through the cases of the enum using a loop, and print the description of each cocktail.


4 (i) Write a closure that takes a single integer as its parameter, and returns that integer multiplied by itself inside a string.

(ii) Write some code to use that closure, by passing in the value 10 (it should print "The result is 100" or similar).

(iii) Now, update the closure and make it take two integers as parameters. Test that closure with 10 and 50 (it should return "The result is 500" or similar).


5. BE the Swift Compiler

Each of the Swift code snippets below represents something about closures. Your job is to play Swift compiler, determine whether each one is valid, and explain why.


iOS移動(dòng)應(yīng)用程序開發(fā) | 第四講-函數(shù)和枚舉:Reusing Code ...的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
延川县| 宜兰县| 巴里| 株洲县| 金门县| 乾安县| 巴楚县| 丰原市| 乌鲁木齐县| 宣威市| 甘孜县| 长宁县| 绵阳市| 博罗县| 宁明县| 阆中市| 桐梓县| 遂溪县| 连平县| 临湘市| 黎川县| 太湖县| 深州市| 博乐市| 冕宁县| 瑞金市| 长海县| 寿宁县| 建宁县| 彩票| 绥江县| 南部县| 台湾省| 临武县| 武川县| 武定县| 宁海县| 九寨沟县| 长春市| 筠连县| 文山县|