セクション 1. 章 10
single
Challenge: Creating a Vehicle Hierarchy
メニューを表示するにはスワイプしてください
タスク
スワイプしてコーディングを開始
Define a class hierarchy for different types of vehicles:
- Create a base class named
Vehiclewith an__init__method that takesbrandandspeedas arguments. - Add a method called
get_infotoVehiclethat returns the brand and speed. - Create a subclass
Carthat inherits fromVehicleand adds adoorsattribute. - Create a subclass
Bikethat inherits fromVehicleand adds atypeattribute (such as'mountain'or'road'). - Override the
get_infomethod in bothCarandBiketo include their extra data (doorsfor cars,typefor bikes).
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 10
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください