Giter Site home page Giter Site logo

beastbattle's Introduction

BeastBattle

Download or clone the C# project BeastBattle.

In this exercise, we will see how several classes can work together for a more complex task. The project is supposed to model a very simple game, where a "hero" can battle a "beast" until either beast or hero is dead! The project contains four classes, which are described in general terms here – see the code for more details:  The NumberGenerator class, with the method GetRandom-NumberInInterval. This is a helper class for generating random numbers.  The BattleLog class, where individual strings can be "saved", and later on printed out on the screen.  The Hero class, which models a game character. It is a very simple character, since it just has a number of hit points (a typical game element; your character has some hit points, and if something damages the character, it loses some hit points. When all hit points are lost, the character dies…  The Beast class, which also models a game character. Actually, the class is very similar to the Hero class…

So, even though this is obviously a very simple setup, it does actually resemble the game mechanics from many popular role-playing games (RPG).

  1. Study the classes in details, so you are sure of what they can do and how they work. Note in particular how the Hero and Beast classes make use of the NumberGenerator and BattleLog classes.

  2. See if you can figure out how to code a battle between a Hero and a Beast (until the death!). This is done in InsertCodeHere.cs. The premade code creates one object of each of the classes. YOUR JOB is to add code that makes the Hero object battle against the Beast object. This will require some thinking, so before starting to code, to try sketch out how a battle proceeds in detail. You will probably need a while-loop in your code .

  3. When you can make the two objects battle each other, there are a number of things to consider afterwards:

a. It seems like the Hero wins most of the time (depending of course on how you coded the battle…. Why is that? How could we make the battle more fair?

b. It looks like the damage dealt by the Hero is always within the interval 10 to 30 points. How could we change that? Could we even let the creator of the Hero object decide this interval? Could this also be done for the number of hit points?

c. Do we really need two separate classes for Hero and Beast? What would we need to add to obtain a more fundamental class like e.g. Character?

d. How could you implement something like weapons and armor, healing abilities, etc.?

beastbattle's People

Contributors

martinkierkegaard avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.