Need a UMLL diagram for these 3 classes please i will like and comment
public class OOP_Ass1 {
public static void main(String[] args) {
GameItem sword = new GameItem("Sword", 1, 10, 5, 0);
GameItem magicStaff = new GameItem("Magic Staff", 2, 0, 10, 5);
Character c1 = new Character("Omar",2231,12,15,44,sword);
Character c2 = new Character("Ahmed",11441,30,40,1000,magicStaff);
c1.Comparison(c2);
System.out.println("Equal? "+c1.equals(c2));
System.out.println("Dublicate? "+c1.dublicate(c2));
Character c3 = new Character(c2);
System.out.println("Copied: "+c3);
System.out.println("");
sword.Comparison(magicStaff);
System.out.println("Equal? " + sword.equals(magicStaff));
GameItem swordDuplicate = new GameItem("Sword", 50, 10, 55, 0);
System.out.println("Duplicate? " + sword.isDuplicate(swordDuplicate));
GameItem swordCopy = sword.copy();
System.out.println("Copied: " + swordCopy);
System.out.println("The expected winner is: "+c1.expectedWinner(c2));
}
}
/////////////////////////
public class GameItem {
private String name;
private int id;
private int strengthModifier;
private int speedModifier;
private int intelligenceModifier;
public GameItem(String name, int id, int strengthModifier, int speedModifier, int
intelligenceModifier) {
this.name = name;
this.id = id;
this.strengthModifier = strengthModifier;
this.speedModifier = speedModifier;
this.intelligenceModifier = intelligenceModifier;
}
public String getName() {
return name;
}
public int getId() {
return id;
}
public int getStrengthModifier() {
return strengthModifier;
}
public int getSpeedModifier() {
return speedModifier;
}
public int getIntelligenceModifier() {
return intelligenceModifier;
}
public void Comparison(GameItem c){
System.out.println("Item 1:\t\tItem 2:");
System.out.println(this.strengthModifier + "\t |\t" + c.strengthModifier);
System.out.println(this.speedModifier+ "\t |\t" + c.speedModifier);
System.out.println(this.intelligenceModifier + "\t |\t" + c.intelligenceModifier);
}
public boolean equals(GameItem other) {
return strengthModifier == other.strengthModifier && speedModifier == other.speedModifier
&& intelligenceModifier == other.intelligenceModifier;
}
// Declare a method that checks if two GameItems are duplicates
public boolean isDuplicate(GameItem other) {
return name.equals(other.name) && id == other.id && equals(other);
}
// Declare a method that creates a copy of a GameItem
public GameItem copy() {
return new GameItem(this.name, this.id, this.strengthModifier, this.speedModifier,
this.intelligenceModifier);
}
@Override
public String toString() {
return "GameItem{" + "name=" + name + ", id=" + id + ", strengthModifier=" +
strengthModifier + ", speedModifier=" + speedModifier + ", intelligenceModifier=" +
intelligenceModifier + '}';
}
}
/////////////////////////////////////////
public class Character {
private String name;
private int id;
private int strength;
private int speed;
private int intelligence;
private GameItem g;
public Character(){
name = "0";
id = 0;
.
Need a UMLL diagram for these 3 classes please i will like and comment.pdf
1. Need a UMLL diagram for these 3 classes please i will like and comment
public class OOP_Ass1 {
public static void main(String[] args) {
GameItem sword = new GameItem("Sword", 1, 10, 5, 0);
GameItem magicStaff = new GameItem("Magic Staff", 2, 0, 10, 5);
Character c1 = new Character("Omar",2231,12,15,44,sword);
Character c2 = new Character("Ahmed",11441,30,40,1000,magicStaff);
c1.Comparison(c2);
System.out.println("Equal? "+c1.equals(c2));
System.out.println("Dublicate? "+c1.dublicate(c2));
Character c3 = new Character(c2);
System.out.println("Copied: "+c3);
System.out.println("");
sword.Comparison(magicStaff);
System.out.println("Equal? " + sword.equals(magicStaff));
GameItem swordDuplicate = new GameItem("Sword", 50, 10, 55, 0);
System.out.println("Duplicate? " + sword.isDuplicate(swordDuplicate));
GameItem swordCopy = sword.copy();
System.out.println("Copied: " + swordCopy);
System.out.println("The expected winner is: "+c1.expectedWinner(c2));
}
}
/////////////////////////
public class GameItem {
private String name;
private int id;
private int strengthModifier;
private int speedModifier;
private int intelligenceModifier;
public GameItem(String name, int id, int strengthModifier, int speedModifier, int
intelligenceModifier) {
2. this.name = name;
this.id = id;
this.strengthModifier = strengthModifier;
this.speedModifier = speedModifier;
this.intelligenceModifier = intelligenceModifier;
}
public String getName() {
return name;
}
public int getId() {
return id;
}
public int getStrengthModifier() {
return strengthModifier;
}
public int getSpeedModifier() {
return speedModifier;
}
public int getIntelligenceModifier() {
return intelligenceModifier;
}
public void Comparison(GameItem c){
System.out.println("Item 1:ttItem 2:");
System.out.println(this.strengthModifier + "t |t" + c.strengthModifier);
System.out.println(this.speedModifier+ "t |t" + c.speedModifier);
System.out.println(this.intelligenceModifier + "t |t" + c.intelligenceModifier);
}
public boolean equals(GameItem other) {
return strengthModifier == other.strengthModifier && speedModifier == other.speedModifier
&& intelligenceModifier == other.intelligenceModifier;
}
// Declare a method that checks if two GameItems are duplicates
public boolean isDuplicate(GameItem other) {
return name.equals(other.name) && id == other.id && equals(other);
}
// Declare a method that creates a copy of a GameItem
3. public GameItem copy() {
return new GameItem(this.name, this.id, this.strengthModifier, this.speedModifier,
this.intelligenceModifier);
}
@Override
public String toString() {
return "GameItem{" + "name=" + name + ", id=" + id + ", strengthModifier=" +
strengthModifier + ", speedModifier=" + speedModifier + ", intelligenceModifier=" +
intelligenceModifier + '}';
}
}
/////////////////////////////////////////
public class Character {
private String name;
private int id;
private int strength;
private int speed;
private int intelligence;
private GameItem g;
public Character(){
name = "0";
id = 0;
strength = 0;
speed = 0;
intelligence = 0;
}
public GameItem getG() {
return g;
}
public void setG(GameItem g) {
this.g = g;
}
public String getName() {
return name;
}
4. public void setName(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getStrength() {
return strength;
}
public int getTotalStrength(){
int total = strength + g.getStrengthModifier();
if (total > 100)
return 100;
return total;
}
public void setStrength(int strength) {
if (strength <= 0)
this.strength = 0;
else if(strength >= 100)
this.strength = 100;
else
this.strength = strength;
}
public int getSpeed() {
return speed;
}
public int getTotalSpeed(){
int total = speed + g.getSpeedModifier();
if (total > 100)
return 100;
5. return total;
}
public void setSpeed(int speed) {
if (speed <= 0)
this.speed = 0;
else if(speed >= 100)
this.speed = 100;
else
this.speed = speed;
}
public int getIntelligence() {
return intelligence;
}
public int getTotalIntelligence(){
int total = intelligence + g.getIntelligenceModifier();
if (total > 100)
return 100;
return total;
}
public void setIntelligence(int intelligence) {
if (intelligence <= 0)
this.intelligence = 0;
else if(intelligence >= 100)
this.intelligence = 100;
else
this.intelligence = intelligence;
}
public Character(String name, int id ,int i , int sp, int st,GameItem g){
this.setId(id);
this.setName(name);
this.setIntelligence(i);
this.setSpeed(sp);
this.setStrength(st);
this.setG(g);
}
public boolean equals(Character c2){