Objectives

The goal of this assignment is to learn the following:

Overview

In lab 6.2 you used blueprint actions and inheritance to create specific super heroes. In this assignment, you will create a class that has several blueprint actions, then inheriting that class and implementing those blueprints in a way so that we create several random superheroes, each with different random attributes from our blueprint class. In order to make the heroes with random attributes, you will use a random number generator, obtained from the Libraries.Compute.Random class.

Requirements

You will need three classes: SuperHeroParts, SuperHeroGenerator, and Main. Class SuperHeroParts will be the base class in which all of the blueprint actions are created. Recall that in Lab 6_2 two categories were defined: super powers and equipment. For this program, create 5 blueprint actions for each of the above categories. As a developer, opportunities will arise where you are able to add your own flare and zest to a program. For this task, feel free to flex your creative muscle and create unique and interesting actions to fulfill the requirements above. Each of these blueprint actions will take one argument, of type text. For example:

//super powers
blueprint action Fly(text name)
blueprint action Strength(text name)
blueprint action LaserVision(text name)

You will also need 1 blueprint action that returns the name of a superhero.

Class SuperHeroGenerator

In this class, you implement all of the blueprint actions inherited from class SuperHeroParts. Recall that the blueprint actions all take 1 argument or type text. This argument will be the name of a character. Your blueprint action that returns the name of a superhero should ask the user to input a name, and then return that text. For example:

action Character() returns text
    text name = input("Enter the name of your superhero")
    return name
end

action Fly(text name)
    say name + "can fly"
end

action Strength(text name)
    say name + "has super human strength!"
end

action LaserVision(text name)
    say name + "can use laser vision"
end

This class will contain four more actions:

Class Main

Class Main should have one action, Main, which instantiates an object of class Random and SuperHeroGenerator. Use the Libraries.Compute.Random in order to create an object of class Random. Use the Random class action RandomIntegerBetween(integer min, integer max), which returns a random integer in the range of (min, max). Set the min to 0, and the max to 50. Main should also call the action CreateHero(integer value, text name) from the derived class SuperHeroGenerator.

Sample Output

When run, the program should ask the user for the name of a superhero, and then should assign the superhero three attributes: one from powers, one from costume, and one from weapons. It will then tell the user what attributes their heroes have. For example:

Enter the name of your Super Hero:
Captain Brandon
Captain Brandon can fly. Captain Brandon wears a mask. Captain Brandon Uses a Hammer.

Next Tutorial

In the next tutorial, we will discuss Assignment 6.3, which describes another practice session with inheritance.