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

iOS移动应用程序开发 | 第七讲-类和对象:Inheritance Is...

2023-01-13 07:49 作者:陈鹏宇老师  | 我要投稿

第七次作业


01:04:14


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

1. Practice making some new instances of Succulent. Create the following Succulents using our Succulent child class from Lecture 7:

  • Elephant's foot (Beaucarnea recurvata)
  • Calico hearts (Adromischus maculatus)
  • Queen victoria (Agave victoria regina)

Once you've done that, create a new child class to represent a Tree. A Tree's type is always "Tree", and its name always has "tree" suffixed to the end of it:

Once you've created a new Tree child class, create some instances of Tree. Create the following Trees using your new Tree child class:

  • European larch (Larix decidua)
  • Red pine (Pinus resinosa)
  • Northern beech (Fagus sylvatica)


2. Here's a class representing a (space) alien. It has a method that can be called to drink.

Create a new child class, for a Klingon (a type of alien), and override the drink method to make a Klingon do something Klingon-y when it drinks (like drinking some blood wine and shouting "ragh!").


3. Who does what?

Test your knowledge of the keywords used for classes and inheritance, and match each keyword on the left to what it does on the right.


4. Pool Puzzle

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.


5. BE the Swift Compiler

Each of the Swift code snippets on page 6 & 7 represents a complete Playground. Your job is to play Swift compiler, and determine whether each of these will run or not. If they run, what do they do? If they don’t run, explain why.


作业二:完成Playgrounds App《开始构建App》剩下的章节。

iOS移动应用程序开发 | 第七讲-类和对象:Inheritance Is...的评论 (共 条)

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