Source Codes from ME

Hello,

please see the source codes from our ME kanina.

 

*************************

public class Character {

private String name;

privateintage;

privatechargender;

private String status;

private String currentResidence;

private String hometown;

privatebooleanisAlive;

privateintstrength;

public Character(String n, int a, char g, String s, String cR, String h, Boolean i, int str)

{

name = n;

age = a;

gender = g;

status = s;

currentResidence = cR;

hometown = h;

isAlive = i;

strength = str;

}

public String getName()

{

returnname;

}

public int getAge()

{

returnage;

}

public char getGender()

{

returngender;

}

public String getStatus()

{

returnstatus;

}

public String getCurrentResidence()

{

return currentResidence;

}

public String getHomeTown()

{

return hometown;

}

public boolean getIsAlive()

{

return isAlive;

}

public int getStrength()

{

return strength;

}

public void setName(String n)

{

name = n;

}

publicvoid setAge(int a)

{

age = a;

}

public void setGender(char g)

{

gender = g;

}

public void setStatus(String s)

{

status = s;

}

public void setCurrentResidence( String cR )

{

currentResidence = cR;

}

public void setHomeTown(String h)

{

hometown = h;

}

publicvoid setIsAlive(boolean i)

{

isAlive = i;

}

public void setStrength( int s )

{

strength = s;

}

public void changeResidence(String s)

{

setCurrentResidence(s);

}

public void returnHome()

{

setCurrentResidence(hometown);

}

public void kill(Character person)

{

person.setIsAlive(false);

}

public static void main(String[] args) {

Character JonSnow = new Character(“Jon Snow”, 28, ‘M’, “Nights Watch”, “Castle Black”, “Winterfell”, true,100 );

Character SansaStark = new Character(“Sansa Stark”, 18, ‘F’, “Lady”, “Castle Black”, “Winterfell”, true,50);

Character CerseiLannister = new Character (“Cersei Lannister”, 32, ‘F’, “Queen Regent”, “Kings Landing”, “Casterley Rock”, true,70);

Character JaimeLannister = new Character (“Jaime Lannister”, 32, ‘M’, “Kings Guard”, “Kings Landing”, “Casterley Rock”, true,120);

Character RamsayBolton = new Character (“Ramsey Bolton”, 28, ‘M’, “Lord of Winterfell”, “Winterfell”, “Dreadfort”, true,90);

System.out.println(JonSnow.getCurrentResidence());

JonSnow.returnHome();

System.out.println(JonSnow.getCurrentResidence());

JonSnow.kill(RamsayBolton);

System.out.println(RamsayBolton.getIsAlive());

}

}

*********************

public class Commoner extends Character {

private Royalty Lord;

public Commoner(String n, int a, char g, String s, String cR, String h, Boolean i, int str, Royalty l) {

super(n, a, g, s, cR, h, i, str);

Lord = l;

// TODO Auto-generated constructor stub

}

public Royalty getLord()

{

returnLord;

}

public void setLord(Royalty l)

{

Lord = l;

}

}

****************************

public class Knight extends Character {

private Royalty Lord;

privateintmoney;

public Knight(String n, int a, char g, String s, String cR, String h, Boolean i, int str, Royalty l, int m) {

super(n, a, g, s, cR, h, i, str);

Lord = l;

money = m;

// TODO Auto-generated constructor stub

}

public Royalty getLord()

{

returnLord;

}

public int getMoney()

{

returnmoney;

}

public void setLord(Royalty l)

{

Lord = l;

}

public void setMoney(int m)

{

money = m;

}

public void kill(Royalty enemyLord)

{

money = money + enemyLord.getMoney();

enemyLord.setIsAlive(false);

}

public void kill(Commoner commonPerson)

{

commonPerson.setIsAlive(false);

}

}

*************************

public class Royalty extends Character {

private String title;

privateintmoney;

public Royalty(String n, int a, char g, String s, String cR, String h, Boolean i, int str, String t, int m) {

super(n, a, g, s, cR, h, i, str);

title = t;

money = m;

}

public String getTitle()

{

returntitle;

}

public int getMoney()

{

returnmoney;

}

public void setTitle(String t)

{

title = t;

}

public void setMoney(int m)

{

money = m;

}

public void BuyCommoner(Commoner name)

{

if (money>= 100)

{

Royalty owner = name.getLord();

owner.setMoney(owner.getMoney()+100);

money = money – 100;

name.setLord(this);

}

}

}