You are on page 1of 17

import java.util.

Scanner;

import java.util.Random;
interface character{ //interface for character constant traits

int heal();

int potionAmount = 40;

int consumedBottled();

int meleeDamage = 20;

int critDamage = 40;

int gunDamage = 40;

int criticalDamage = 80;

int tookDamage();

int tookCrit();

int tookBossDam();

int tookBossCrit();

interface zombie{ //interface for zombie constant traits

int zomDamage = 20;

int zomDamageCrit = 40;

int damagedZom();

int damagedZomCrit();

int gunDamaged();

int gunCrit();

interface movement{ //interface for reusable movement methods


void walk();

void driveCar();

interface finalBoss{ //interface for boss traits and boss battle

int bossDamage = 60;

int critBossDam = 90;

int fBosTookDam();

int fbosTookCrit();

void bossBattle();

public class zombieBrrtBrrt implements character, zombie, movement, finalBoss{

static int bossHealth = 150; //global variables that are not final so it can be changeable

static int healthPotion = 3;

static int charHealth = 100;

static int zomHealth = 100;

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

zombieBrrtBrrt obj = new zombieBrrtBrrt();

System.out.print("Enter your name: ");

String charName = scan.nextLine();

System.out.println("Welcome to Residence Evil IV(no copyright infringement intended),


" + charName + ".");

System.out.println("you are tasked to find and rescue the president's daughter that has
been kidnapped. unusual entities are roaming "
+ "the earth which are called \nzombie\n");

System.out.print("press 1 to start game. press any other key to quit game. \n");

String start = scan.nextLine();

if(start.equals("1")) {

System.out.println("You are now deployed, you are seeing two houses. press 1
to enter first house, press 2 otherwise. ");

boolean meh = true;

int house = scan.nextInt();

switch(house) {

case 1:

System.out.println("you saw a gun.");

System.out.println("***gun acquired***");

break;

case 2:

System.out.println("THERE'S A ZOMBIE!!!");

System.out.println("You only have your melee weapon.


do you wish to fight or retreat?");

System.out.println("1.YES 2.NO");

int house2Fight = scan.nextInt();

switch(house2Fight) {

case 1:

while(meh)

System.out.println("Your
health:" + charHealth);

System.out.println("Enemies
health: " + zomHealth + "\n");
System.out.println("press 1 to
attack. press 2 to heal. press any other key to retreat");

String starter = scan.next();

if(starter.equals("1")) {

Random rand = new


Random();

int rand_int1 =
rand.nextInt(51);

int rand_int2 =
rand.nextInt(51);

if(rand_int1 <=
24) {

System.out.println("You damaged the enemy by :" + meleeDamage);

obj.damagedZom();

else
if(rand_int1 >= 25) {

System.out.println("You damaged the enemy by :" + critDamage);

obj.damagedZomCrit();

else {

System.out.println("You missed");

if(rand_int2 <=
24) {

System.out.println("Zombie damaged you by: " + zomDamage);


obj.tookDamage();

else
if(rand_int2 >= 25) {

System.out.println("Zombie damaged you by: " + zomDamageCrit);

obj.tookCrit();

else {

System.out.println("you dodged zombie attack");

if(zomHealth <=
0) {

System.out.println("You killed the zombie.");

meh =
false;

System.out.println("Your health:" + charHealth);

System.out.println("press any key to heal");

scan.next();

obj.heal();

obj.consumedBottled();

System.out.println("You only have " + healthPotion + " health potions left.");

}
else
if(charHealth <= 0) {

System.out.println("you got eaten, try again \n");

charHealth = 100;

zomHealth = 100;

else if(starter.equals("2")) {

if(healthPotion <= 0) {

System.out.println("you have no potions left huhuhu");

else {

obj.heal();

obj.consumedBottled();

System.out.println("You
only have " + healthPotion + " health potions left.");

else {

meh = false;

case 2:

System.out.println("***you went to
house 1 and acquired gun***");
break;

default:

System.out.println("\n***");

break;

break;

default:

System.out.println("wrong input. game crashed");

System.out.println("You must find a vehicle for traveling.");

for(int i = 1; i <=3; i++) {

System.out.println("press any key to walk");

scan.next();

obj.walk();

System.out.println("***after minutes of walking, " + charName + " found a


car***");

System.out.println(charName +":bingo just what i needed!");

obj.driveCar();

System.out.println("You found the chapel where the president's daughter has


been held captive");

boolean bossbatt = true;

while(bossbatt) {

System.out.println("Do you want to enter the chapel or check or check


around first?");

System.out.println("1.Enter Chapel 2.Check Around first");

String bossBatt = scan.next();

if(bossBatt.equals("1")) {
obj.bossBattle();

bossbatt = false;

else {

System.out.println("you found 3 health potions");

healthPotion += 3;

System.out.println("WEll DONE YOU BEAT THE GAME!!!");

else {

System.out.println("Quitting game.");

@Override

public int heal() {

return charHealth += potionAmount;

@Override

public int damagedZom() {

return zomHealth -= meleeDamage;

@Override

public int damagedZomCrit() {


return zomHealth -= critDamage;

@Override

public int tookDamage() {

// TODO Auto-generated method stub

return charHealth -= zomDamage;

@Override

public int tookCrit() {

// TODO Auto-generated method stub

return charHealth -= zomDamageCrit;

@Override

public int consumedBottled() {

// TODO Auto-generated method stub

return healthPotion -= 1;

@Override

public void walk() {

System.out.println("***walking***");

Random randM = new Random();

Scanner scan = new Scanner(System.in);

int rand_int = randM.nextInt(51);

int rand_int1 = randM.nextInt(51);


int rand_int2 = randM.nextInt(51);

if(rand_int <= 10) {

System.out.println("THERES A ZOMBIEE");

boolean fight = true;

while(fight) {

System.out.println("Your health:" + charHealth);

System.out.println("Enemies health: " + zomHealth + "\n");

System.out.println("press 1 to attack. press 2 to heal. press any


other key to retreat");

String starter = scan.next();

if(starter.equals("1")) {

if(rand_int1 <= 24) {

System.out.println("You damaged the enemy by


:" + gunDamage);

gunDamaged();

else if(rand_int1 >= 25) {

System.out.println("You damaged the enemy by


:" + criticalDamage);

gunCrit();

else {

System.out.println("You missed");

if(rand_int2 <= 24) {

System.out.println("Zombie damaged you by: "


+ zomDamage);

tookDamage();

else if(rand_int2 >= 25) {


System.out.println("Zombie damaged you by: "
+ zomDamageCrit);

tookCrit();

else {

System.out.println("you dodged zombie


attack");

if(zomHealth <= 0) {

System.out.println("You killed the zombie.");

fight = false;

System.out.println("Your health:" + charHealth);

else if(charHealth <= 0) {

System.out.println("you got eaten, try again \


n");

charHealth = 100;

zomHealth = 150;

else if(starter.equals("2")) {

if(healthPotion <= 0) {

System.out.println("you have no potions left


huhuhu");

else {

heal();

consumedBottled();

}
System.out.println("You only have " + healthPotion + "
health potions left.");

else {

fight = false;

@Override

public void driveCar() {

System.out.println("***starts car and drive***");

@Override

public int gunDamaged() {

// TODO Auto-generated method stub

return zomHealth -= gunDamage;

@Override

public int gunCrit() {

// TODO Auto-generated method stub

return zomHealth -= criticalDamage;

}
@Override

public int tookBossDam() {

// TODO Auto-generated method stub

return charHealth -= bossDamage;

@Override

public int tookBossCrit() {

// TODO Auto-generated method stub

return charHealth -= critBossDam;

@Override

public int fBosTookDam() {

// TODO Auto-generated method stub

return bossHealth -= gunDamage;

@Override

public int fbosTookCrit() {

// TODO Auto-generated method stub

return bossHealth -= criticalDamage;

@Override

public void bossBattle() {

Random randM = new Random();

int rand_int = randM.nextInt(51);

int rand_int1 = randM.nextInt(51);


Scanner scan = new Scanner(System.in);

System.out.println("THE PRESIDENTS DAUGHTER IS BEING CAPTIVE IN THE CHAPEL


ROOMN\n"

+ "BUT THERE IS A ZOMBIE WITH A CHAINSAW BLOCKING THE ROOM.


YOU MUST FIGHT IT FIRST TO RESCUE\n"

+ "THE PRESIDENTS DAUGHETR");

boolean fight = true;

while(fight) {

System.out.println("Your health:" + charHealth);

System.out.println("Enemies health: " + bossHealth + "\n");

System.out.println("press 1 to attack. press 2 to heal. press any other key to


retreat");

String starter = scan.next();

if(starter.equals("1")) {

if(rand_int <= 24) {

System.out.println("You damaged the enemy by :" +


gunDamage);

fBosTookDam();

else if(rand_int >= 25) {

System.out.println("You damaged the enemy by :" +


criticalDamage);

fbosTookCrit();

else {

System.out.println("You missed");

if(rand_int1 <= 24) {

System.out.println("Boss damaged you by: " + bossDamage);

tookBossDam();
}

else if(rand_int1 >= 25) {

System.out.println("Boss damaged you by: " + critBossDam);

tookBossCrit();

else {

System.out.println("you dodged boss attack");

if(bossHealth <= 0) {

System.out.println("You killed the boss. and you rescued


Ashley");

fight = false;

else if(charHealth <= 0) {

System.out.println("you got eaten, try again \n");

charHealth = 100;

bossHealth = 150;

else if(starter.equals("2")) {

if(healthPotion <= 0) {

System.out.println("you have no potions left huhuhu");

else {

heal();

consumedBottled();

}
System.out.println("You only have " + healthPotion + " health potions
left.");

else {

fight = false;

You might also like