最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(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ó)家法律
凤庆县| 彭州市| 六安市| 双柏县| 繁昌县| 上虞市| 依兰县| 克山县| 辽宁省| 荣成市| 固镇县| 台东县| 疏附县| 昭觉县| 德钦县| 渝中区| 福清市| 读书| 唐海县| 集安市| 甘泉县| 宁晋县| 清水河县| 潢川县| 车致| 资兴市| 洪泽县| 汝南县| 武隆县| 丽水市| 修武县| 巴彦县| 高阳县| 邻水| 桦甸市| 始兴县| 奈曼旗| 新郑市| 南安市| 藁城市| 乐山市|