Changes between Version 4 and Version 5 of ControlSystems/SoftwareTeam/Training/GettingStarted/JavaExercises


Ignore:
Timestamp:
Nov 14, 2016, 8:09:43 PM (9 years ago)
Author:
azhang
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/Training/GettingStarted/JavaExercises

    v4 v5  
    1414Another challenge: Animal Farm
    1515Create an `abstract class` called `Animal` that has a `mass` and a `name`
    16 *All animals should have a constructor which gives them a `mass` and a `name` when they are created
    17 *All animals can `eat` an `amount`, which increases their `mass` by `amount`
    18 *All animals can also `move` a `distance`, which decreases their `mass` by `distance`
    19 *Everybody can use `getName` to get the name of an animal
    20 *Everybody can use `getMass` to get the mass of an animal
     16* All animals should have a constructor which gives them a `mass` and a `name` when they are created
     17* All animals can `eat` an `amount`, which increases their `mass` by `amount`
     18* All animals can also `move` a `distance`, which decreases their `mass` by `distance`
     19* Everybody can use `getName` to get the name of an animal
     20* Everybody can use `getMass` to get the mass of an animal
    2121
    2222Create a class called `Cat` that `extends Animal`
    23 *When a cat `speak`, it prints `Meow!`
     23* When a cat `speak`, it prints `Meow!`
    2424
    2525Create a class called `Dog` that `extends Animal`
    26 *When a dog `speak`, it prints `Woof!`
     26* When a dog `speak`, it prints `Woof!`
    2727
    2828Create a class called `Farm`
    29   -The `Farm` has a `main` method
    30   -In the `main` method, the `Farm` creates a `Cat` with a `mass` of `12.2` named `Cloud`
    31   -In the `main` method, the `Farm` creates a `Dog` with a `mass` of `15.4` named `Spot`
     29* The `Farm` has a `main` method
     30* In the `main` method, the `Farm` creates a `Cat` with a `mass` of `12.2` named `Cloud`
     31* In the `main` method, the `Farm` creates a `Dog` with a `mass` of `15.4` named `Spot`
    3232
    3333In the `main` method, the `Farm` will print the names of both animals and their masses.
    34     -Ex. `Spot is a Dog with a mass of 15.4.`
     34* Ex. `Spot is a Dog with a mass of 15.4.`
    3535Then, `Cloud` will `eat` `0.2`, `move` `0.8`, and `speak`.
    3636`Spot` will then `eat` `0.4`,  `move` `0.6`, and `speak`.