Can you just write the documentation of these code? public class Hydron extends
ID: 3838990 • Letter: C
Question
Can you just write the documentation of these code?
public class Hydron extends Monster {
private Polygon triangle = new Polygon();
private double monster1X = 60.0, monster1Y = 0.0;
private double monster2X = 120.0, monster2Y = 100.0;
private double monster3X = 0.0, monster3Y = 100.0;
Label rollLabel = new Label();
Label hLabel = new Label("Health: " + this.health);
public Hydron(String name) {
super(name);
Label nameField = new Label(name);
setMargin(triangle, new Insets(0, 0, 0, 0));
setMargin(nameField, new Insets(0, 0, 5, 0));
setAlignment(Pos.CENTER);
triangle.getPoints().addAll(monster1X, monster1Y, monster2X, monster2Y, monster3X, monster3Y);
getChildren().add(triangle);
getChildren().add(nameField);
getChildren().add(hLabel);
}
public Polygon getTriangle() {
return triangle;
}
@Override
// change the size of the Hydrons
public void sizeChange() {
monster1X = (monster1X / 25) * health;
monster2X = (monster2X / 25) * health;
monster2Y = (monster2Y / 25) * health;
monster3Y = (monster3Y / 25) * health;
hLabel.setText("Health: " + this.health);
triangle.getPoints().setAll(monster1X, monster1Y, monster2X, monster2Y, monster3X, monster3Y);
System.out.println("Monster 1 X: " + monster1X);
System.out.println("Monster 2 X: " + monster2X);
System.out.println("Monster 2 Y: " + monster2Y);
System.out.println("Monster 3 X: " + monster3X);
}
}
_____________________________________
public class Zexor extends Monster {
private double sides = 100;
private String name;
protected Rectangle square = new Rectangle(sides, sides);
Label hLabel = new Label("Health: " + this.health);
public Zexor(String name) {
super(name);
Label nameField = new Label(name);
setMargin(square, new Insets(0, 0, 10, 10));
setMargin(nameField, new Insets(0, 0, 10, 0));
setAlignment(Pos.CENTER);
getChildren().add(hLabel);
getChildren().add(square);
getChildren().add(nameField);
}
public void setSide(double newSides) {
this.sides = newSides;
}
public double getSides() {
return sides;
}
@Override
public void sizeChange() {
sides = (sides / 25) * health;
hLabel.setText("Health: " + this.health);
square.setHeight(sides);
square.setWidth(sides);
System.err.println("Side: " + sides);
}
public Rectangle getSquare() {
return square;
}}
Explanation / Answer
/**
* Hydron is a concrete class which is extending from Monster class It contains
* six global variables. This class is used for setting polygon
* margin,border,label text and also provides size changing functionality
*
* @author Name
* @version 1.0
* @since 1.0
*
*/
public class Hydron extends Monster {
/**
* Polygon is used for creating polygon shapes by using x and y coordinates
* a polygon comprises of a list of (x,y) coordinate pairs
*/
private Polygon triangle = new Polygon();
/**
* contains 1X and 1Y axis values
*/
private double monster1X = 60.0, monster1Y = 0.0;
/**
* contains 2X and 2Y axis values
*/
private double monster2X = 120.0, monster2Y = 100.0;
/**
* contains 3X and 3Y axis values
*/
private double monster3X = 0.0, monster3Y = 100.0;
/**
*
* It is used for placing text in to a container It will only displays
* single line of read-only-text This text only changed by the application
* user cannot edit directly
*/
Label rollLabel = new Label();
Label hLabel = new Label("Health: " + this.health);
/**
* This is String argument Constructor while initializing Hydron object it is
* setting label name,triangle margin and alignment
*
* @param name
* used for initializing super class String constructor also used
* for label text
*/
public Hydron(String name) {
super(name);
Label nameField = new Label(name);
setMargin(triangle, new Insets(0, 0, 0, 0));
setMargin(nameField, new Insets(0, 0, 5, 0));
setAlignment(Pos.CENTER);
triangle.getPoints().addAll(monster1X, monster1Y, monster2X, monster2Y, monster3X, monster3Y);
getChildren().add(triangle);
getChildren().add(nameField);
getChildren().add(hLabel);
}
/**
* This method used for getting Polygon object
*
* @return Polygon
* @see Polygon
*/
public Polygon getTriangle() {
return triangle;
}
/**
* This is override method Main functionality of this method is changing the
* size of polygon
*
* @return void
*/
@Override
// change the size of the Hydrons
public void sizeChange() {
monster1X = (monster1X / 25) * health;
monster2X = (monster2X / 25) * health;
monster2Y = (monster2Y / 25) * health;
monster3Y = (monster3Y / 25) * health;
hLabel.setText("Health: " + this.health);
triangle.getPoints().setAll(monster1X, monster1Y, monster2X, monster2Y, monster3X, monster3Y);
System.out.println("Monster 1 X: " + monster1X);
System.out.println("Monster 2 X: " + monster2X);
System.out.println("Monster 2 Y: " + monster2Y);
System.out.println("Monster 3 X: " + monster3X);
}
}
------------------------------------------------------------------------------------------------
/**
* Zexor is a concrete class which is extending from Monster class It contains
* three global variables. This class is used for setting Rectangle height
* width, label text and also provides size changing functionality
*
* @author Name
* @version 1.0
* @since 1.0
*
*/
public class Zexor extends Monster {
/**
* double value is used for setting height and with of The rectangle
*/
private double sides = 100;
/**
* used for label text
*/
private String name;
/**
* This rectangle is used for creating square shape.It will only takes
* positive values as width and height
*/
protected Rectangle square = new Rectangle(sides, sides);
/**
*
* It is used for placing text in to a container It will only displays
* single line of read-only-text This text only changed by the application
* user cannot edit directly
*/
Label hLabel = new Label("Health: " + this.health);
/**
* This is String argument Constructor while initializing Zexor object it is
* setting label name,square margin and alignment
*
* @param name
* used for initializing super class String constructor also used
* for label text
*/
public Zexor(String name) {
super(name);
Label nameField = new Label(name);
setMargin(square, new Insets(0, 0, 10, 10));
setMargin(nameField, new Insets(0, 0, 10, 0));
setAlignment(Pos.CENTER);
getChildren().add(hLabel);
getChildren().add(square);
getChildren().add(nameField);
}
/**
* sets the sides field
*
* @param newSides
* initializes sides field
*/
public void setSide(double newSides) {
this.sides = newSides;
}
/**
* Gets the sides value
*
* @return sides current sides value will be returned
*/
public double getSides() {
return sides;
}
/**
* This is override method Main functionality of this method is changing the
* size of square by setting height and width values it will also alters label text.
*
* @return void
*/
@Override
public void sizeChange() {
sides = (sides / 25) * health;
hLabel.setText("Health: " + this.health);
square.setHeight(sides);
square.setWidth(sides);
System.err.println("Side: " + sides);
}
/**
* Returns the current rectangle object witch contains the square shape object
* @return Rectangle returns the current rectangle object
*/
public Rectangle getSquare() {
return square;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.