oo-70-245-1

oo-70-245-1 Commit Details


Date:2015-10-14 12:34:52 (9 years 1 day ago)
Author:Natalie Adams
Branch:master
Commit:300d1a3d47f31f8bfc0a4e7823340322ad599faa
Parents: f7e69ab6d2f63017f8f79e2aadc28318a95986fb
Message:Adding Homework 1 help

Changes:

File differences

Homework 1 - base.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Defining the class
// We marked it as abstract instead of interface because we defined implementations for the Health and Type properties
abstract class Enemy {
// Defining variables which will be referenced by the properties
protected int _health;
protected string _type;
// Defining the properties
// health property
public int Health {
get { return _health; }
set { _health = value; }
}
// type property
public string Type {
get { return _type; }
set { _type = value; }
}
// Defining our speak and attack methods
// marking it as abstract so that whoever inherits from our Enemy class must provide an implementation of speak and attack
public abstract void Speak();
public abstract void Attack(Player p);
}
// Creating 2 enemies
// Note how they implemented the abstract methods defined in the Enemy class
class Paladin : Enemy {
public void Speak() { //do something }
public void Attack(Player p) { //do something }
}
class Wizard : Enemy {
public void Speak() { // do something }
public void Attack(Player p) { //do something }
}
// Defining a player class per the homework
class Player {
protected int _health;
// Defining the properties
// health property
public int Health {
get { return _health; }
set { _health = value; }
}
public void Attack(Enemy e) { // do something }
}

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.05768s using 14 queries.