Character.java

import java.util.Random; /** * * This is Base code for IST 140 - Lab 4 * Character represent a character in an RPG type * game. The character has a name, type, health points, * shield points, weapon damage, and life indicator * * Place the answers to the Questions here: * 1. * 2. * * @author smv159 * @version 1.0 */ public class Character { //Create the field variables here //Create the constructor here //Create the get methods for the field variables //Create the set methods for the field variables //Create the takeDamage method /* * Start by trying to reduce the shield amount first. * If the shield value is 0, move on to health. * If the shield value is > 0, then reduce the sheild based on the damage amount. * If the damage amount is greater than the shield value, reduce the shield to 0 and go to the health. * * If the health value is 0, then reduce lives by 1 * If the health value is > 0, then reduce the health base on the damage amount remaining. * If the damage amount is greater than the health value, reduce the lives by 1 * * If the lives is less than or equal to 0, then: * print out that the Character (use the name value) is no longer alive. * call the following command: System.exit(0); */ //Create the toString method public static void main(String[] args) { Character fl4k = new Character("FL4K", 2, 9500, 8225, 1350); Character bandit = new Character("Mouthpiece", 0, 12200, 3540, 905); Random rand = new Random(); while(fl4k.getLives() > 0 && bandit.getLives() > 0) { int player = rand.nextInt(2); if (player == 0) { bandit.takeDamage(fl4k.getDamage()); } else { fl4k.takeDamage(bandit.getDamage()); } } } }