Course Solutions Uncategorized (Solved) : Exercise Create Subclass Note Exercises Based Game Spaceship Avoids Obstacles Space Ship P Q31764434 . . . .

(Solved) : Exercise Create Subclass Note Exercises Based Game Spaceship Avoids Obstacles Space Ship P Q31764434 . . . .

 

Exercise – Create a Subclass

Note:

The exercises below are based on a game where a spaceship avoidsobstacles in space. The ship is positioned at the bottom of acoordinate system and can only move left and right while obstacles”fall” from top to bottom. Throughout the exercises, you’ll createclasses to represent different types of spaceships that can be usedin the game. The base class Spaceship has been provided for youbelow.

class Spaceship {

var name: String = “”

var health = 100

var position = 0

  

func moveLeft() {

position -= 1

}

  

func moveRight() {

position += 1

}

  

func wasHit() {

health -= 5

}

}

Define a new class Fighter that inherits from Spaceship. Add

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post