Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A better way of writing code #5

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Binary file modified out/production/DCUniverse/characters/Characters.class
Binary file not shown.
Binary file modified out/production/DCUniverse/characters/Heroes.class
Binary file not shown.
Binary file modified out/production/DCUniverse/characters/Villains.class
Binary file not shown.
16 changes: 15 additions & 1 deletion src/characters/Characters.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
/**
* Created by navenprasad25 on 03/04/2015.
*/

//Edited by Yk on 7/4/15
public abstract class Characters {
protected int life;
private String name;
protected boolean alive;

Expand All @@ -24,9 +27,20 @@ public String getName(){
public boolean isAlive(){
return alive;
}
public int getLife(){
return life;
}

public boolean checkAlive() {
if(life <= 0)
alive = false;
return alive;
}


public void takeDamage(int damage){
life = life - damage;
}
public abstract int fight();
}


23 changes: 2 additions & 21 deletions src/characters/Heroes.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,9 @@
/**
* Created by navenprasad25 on 03/04/2015.
*/
public abstract class Heroes extends Characters{
protected int life;

//Edited by Yk on 7/4/15
public class Heroes extends Characters{
Heroes(String name){
super(name);
}

public int getLife(){
return life;
}

public boolean checkAlive() {
if(life <= 0)
alive = false;
return alive;
}

public void takeDamage(int damage){
life = life - damage;
}


public abstract int fight();

}
24 changes: 2 additions & 22 deletions src/characters/Villains.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,9 @@
/**
* Created by navenprasad25 on 03/04/2015.
*/
public abstract class Villains extends Characters {

protected int life;

//Edited by Yk on 7/4/15
public class Villains extends Characters {
Villains(String theName){
super(theName);
}

public int getLife(){
return life;
}

public boolean checkAlive() {
if(life <= 0)
alive = false;
return alive;
}

public void takeDamage(int damage){
life = life - damage;
}


public abstract int fight();

}