Results 1 to 4 of 4
  1. #1
    magichaxx is offline Member
    Join Date
    Nov 2013
    Posts
    27
    Rep Power
    0

    Exclamation Java Eclipse Help! - DUE BY NOON

    I really need help understanding instructions better. I'm improving though, but I still seriously need help. Below are chunks of instructions along with their respective chunks of code. These are what I need help clarifying. If they're right, just say so, otherwise please help:

    Create a class called Armor to represent a rectangular plate of armor. Update your Armor class so that it has the following state and behavior:
    ...
    section : Section An enumerated type that has the values NONE, FRONT, REAR, LEFT, RIGHT, HEAD, TORSO, LEG, and ARM. Declare this type in the Armor class, and then create the an instance variable named section of type Section.
    ...
    Armor() : Armor Empty constructor to initialize a piece of armor; should set default values width = 1, height = 1, thickness = 1, condition = 1, section = NONE

    Armor(double width, double height, double thickness, double condition, Section section) : Armor Constructor to initialize a piece of armor, setting appropriate instance data from the given parameters.
    ...
    Accessors and mutators for all non-constant instance data.
    Java Code:
    public class Armor
    {
    	private double width;
    	private double height;
    	private double thickness;
    	private double condition;
    	private Section section;
    	
    	public enum Section
    	{
    		NONE, FRONT, REAR, LEFT, RIGHT, HEAD, TORSO, LEG, ARM
    	}
    	
    	public Armor()
    	{
    		width = 1;
    		height = 1;
    		thickness = 1;
    		condition = 1;
    		section = Section.NONE;
    	}        
    //the following getter and setter is used the same way for each variable
        public double getWidth()
    	{
    		return width;
    	}
    	public void setWidth(double width)
    	{
    		this.width = width;
    	}
    Create a BodyArmor class and give it the following state and behavior:
    ...
    BodyArmor(Armor headArmor, Armor torsoArmor, Armor legArmor, Armor armArmor) : BodyArmor Constructor to initialize a piece of armor, setting appropriate instance data from the given parameters.
    ...
    Accessors and mutators for all non-constant instance data.
    Java Code:
    public class BodyArmor
    {
    	private Armor headArmor;
    	private Armor torsoArmor;
    	private Armor legArmor;
    	private Armor armArmor;
    	
    	public BodyArmor(Armor headArmor, Armor torsoArmor, Armor legArmor, Armor armArmor)
    	{
    		this.headArmor = headArmor;
    		this.torsoArmor = torsoArmor;
    		this.legArmor = legArmor;
    		this.armArmor = armArmor;
    	}
    //the following getter and setter is used the same way for each variable
        public Armor getHeadArmor()
    	{
    		return headArmor;
    	}
    	public void setHeadArmor(Armor headArmor)
    	{
    		this.headArmor = headArmor;
    	}
    Create a Person class and give it the following state and behavior:
    ...
    Person(String name) : Person Constructor to initialize a person. Armor should default to null and alive should default to true.

    Person(String name, BodyArmor armor) : Person Constructor to initialize a person. Alive should default to true.

    impact(Armor.Section section, double damage) : void Reduces the condition of the indicated section of armor by the percentile amount given by damage. If the condition of the armor drops to zero or less, set the body armor's reference to that section of armor to null. If the indicated section of armor is already null, set alive to false (i.e. the person is killed).

    Accessors and mutators for all non-constant instance data.
    Java Code:
    public class Person
    {
    	private String name;
    	private BodyArmor armor;
    	private boolean alive;
    	
    	public Person(String name)
    	{
    		armor = null;
    		alive = true;
    	}
    	public Person(String name, BodyArmor armor)
    	{
    		this.alive = true;
    	}
    	public void impact(Armor.Section section, double damage)
    	{
    		//???
    	}
    Create a Tank class and give it the following state and behavior:
    ...
    impact(Armor.Section section, double damage) : void Reduces the condition of the indicated section of armor by the percentile amount given by damage. If the condition of the armor drops to zero or less, set the tank's reference for that section of armor to null. If the indicated section of armor is already null, set alive for each Person in the tank to false (i.e. all occupants are killed).

    Accessors and mutators for all non-constant instance data.
    Java Code:
    public class Tank
    {
    	private Armor frontArmor;
    	private Armor rearArmor;
    	private Armor leftArmor;
    	private Armor rightArmor;
    	private Person driver;
    	private Person gunner;
    	private Person commander;
    	
    	public void impact(Armor.Section section, double damage)
    	{
    		//???
    	}

  2. #2
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,914
    Rep Power
    5

    Default Re: Java Eclipse Help! - DUE BY NOON

    Well your Armor class is already missing a constructor with parameters. Perhaps you want to run the instructions yourself one more time.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    magichaxx is offline Member
    Join Date
    Nov 2013
    Posts
    27
    Rep Power
    0

    Default Re: Java Eclipse Help! - DUE BY NOON

    sorry i forgot to include that
    Java Code:
    public Armor(double width, double height, double thickness, double condition, Section section)
    	{
    		this.width = width;
    		this.height = height;
    		this.thickness = thickness;
    		this.condition = condition;
    		this.section = section;
    	}

  4. #4
    magichaxx is offline Member
    Join Date
    Nov 2013
    Posts
    27
    Rep Power
    0

Similar Threads

  1. Replies: 2
    Last Post: 10-11-2013, 09:26 AM
  2. Replies: 5
    Last Post: 07-25-2012, 04:11 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •