I'm just trying to Override and use the toString method to print some information about my classes.
Can someone please provide advice as to how I would do this?
I've never done this before, and I'm becoming stuck.
My Base Class:
public class Vehicle {
int seatNumber;
int numberMade;
int yearMade;
public Vehicle(int seatNumber, int numberMade, int yearMade) {
this.seatNumber = seatNumber;
this.numberMade = numberMade;
this.yearMade = yearMade;
}
public int getSeatNumber() {
return seatNumber;
}
public int getNumberMade() {
return numberMade;
}
public int getYearMade() {
return yearMade;
}
}
A derived class:
public class Car extends Vehicle {
public int topSpeed;
public Car(int seatNumber, int numberMade, int yearMade, int topSpeed) {
this.seatNumber = seatNumber; //takes the value you pass as parameter
this.numberMade = numberMade; // and stores it into the instance variable
this.yearMade= yearMade;
this.topSpeed = topSpeed;
}
}
Main Class:
public class Assignment2 {
public static void main(String[] args) {
Car myCar = new Car(5, 20000, 1998, 180);
Motorbike myMotorbike = new Motorbike(1, 5000, 2015, 300);
System.out.println(myCar);
System.out.println(myMotorbike);
}
}
You can do it like this:
public class Vehicle {
int seatNumber;
int numberMade;
int yearMade;
// Getters, setters, constructor, etc
#Override
public String toString() {
return String.format("[Vehicle] seats: %d, number made: %d, yearMade %d", seatNumber, numberMade, yearMade);
}
}
Same for the other Class
I'm just trying to Override and use the toString method to print some information about my classes
There are 2 ways you can override a method in the subclass.
Override by modification
Override it with new implementation
Can someone please provide advice as to how I would do this?
Overridding in Java is very simple. Just rewrite the method with similar method signature in the subclass according to the method in its super class.
Below shows an example of overriding by modification:
class Animal
{
#Override
public String toString(){
return "An animal";
}
}
class CatFamily extends Animal{
#Override
public String toString(){
return super.toString() + " from the cat family.";
}
}
class Lion extends CatFamily{
#Override
public String toString(){
return super.toString() + " - A Lion";
}
}
Create a super & subclass instance for testing:
public static void main(String[] args)
{
System.out.println(new Animal());
System.out.println(new CatFamily());
System.out.println(new Lion());
}
OUTPUT:
An animal
An animal from the cat family.
An animal from the cat family. - A Lion
Related
I am doing a coding boot camp and created a Superclass "Animal" with a subclass "Lion". All the variables are private variables.
When I try and pass in the values required I get an error saying Lion cannot be resolved to a type. This is my first question ever asked on StackOverflow, so sorry if the normal convention isn't followed right.
///Animal class with subclass lion///
public class Animal {
private int numTeeth;
private boolean spots;
private int weight;
public Animal(int numTeeth, boolean spots, int weight) {
this.setNumTeeth(numTeeth);
this.setSpots(spots);
this.setWeight(weight);
}
int getNumTeeth() {
return numTeeth;
}
boolean getSpots() {
return spots;
}
int getWeight() {
return weight;
}
public void setNumTeeth(int numTeeth) {
this.numTeeth = numTeeth;
}
public void setSpots(boolean spots) {
this.spots = spots;
}
public void setWeight(int weight) {
this.weight = weight;
}
class Lion extends Animal {
private boolean maine;
private String region;
private int type;
public Lion(boolean maine, String region, int type) {
super(numTeeth, spots, weight);
this.setMaine(maine);
this.setRegion(region);
this.setType(type);
}
boolean getMaine() {
return maine;
}
String getRegion() {
return region;
}
int getType() {
return type;
}
public void setMaine(boolean maine) {
this.maine = maine;
}
public void setRegion(String region) {
this.region = region;
}
public void setType(int type) {
this.type = type;
}
void showAnimal() {
System.out.println("The number of teeth is: " + getNumTeeth());
System.out.println("Does the animal have spots!: " + getSpots());
System.out.println("The animals weight!: " + getWeight());
System.out.println("Do the animal have a maine!: " + getMaine());
System.out.println("The animal is from: " + getRegion());
System.out.println("The animal is a: " + getType());
}
}
}
///Animal stats I am trying to pass in "AnimalDetails" which is a new class file///
public class AnimalStats {
public static void main(String[] args) {
Lion stats = new Lion();
stats.setMaine(true);
stats.setNumTeeth(20);
stats.setRegion("South Africa");
stats.setSpots(false);
stats.setType(2);
stats.setWeight(150);
}
}
The error I find is in / Lion stats = new Lion(); / Lion cannot be reloved to a type
Lion is not declared static
In order to construct Lion in the way you are, Lion should be a static inner class.
The declared constructor in Lion does not include params for super
Add params for the call to super, or provide default values inside the constructor implementation for numTeeth, spots, and weight when you call super.
Lion does not have a zero-argument constructor
Your code is trying to instantiate a Lion with no arguments. If you want a zero-argument constructor, add one and set defaults for all of the members.
Otherwise, call the constructor you've already defined.
Something like:
public class Animal {
private int numTeeth;
private boolean spots;
private int weight;
public Animal(int numTeeth, boolean spots, int weight) {
this.setNumTeeth(numTeeth);
this.setSpots(spots);
this.setWeight(weight);
}
int getNumTeeth() {
return numTeeth;
}
boolean getSpots() {
return spots;
}
int getWeight() {
return weight;
}
public void setNumTeeth(int numTeeth) {
this.numTeeth = numTeeth;
}
public void setSpots(boolean spots) {
this.spots = spots;
}
public void setWeight(int weight) {
this.weight = weight;
}
static class Lion extends Animal {
private boolean maine;
private String region;
private int type;
public Lion(boolean maine, String region, int type, int numTeeth, boolean spots, int weight) {
super(numTeeth, spots, weight);
this.setMaine(maine);
this.setRegion(region);
this.setType(type);
}
boolean getMaine() {
return maine;
}
String getRegion() {
return region;
}
int getType() {
return type;
}
public void setMaine(boolean maine) {
this.maine = maine;
}
public void setRegion(String region) {
this.region = region;
}
public void setType(int type) {
this.type = type;
}
void showAnimal() {
System.out.println("The number of teeth is: " + getNumTeeth());
System.out.println("Does the animal have spots!: " + getSpots());
System.out.println("The animals weight!: " + getWeight());
System.out.println("Do the animal have a maine!: " + getMaine());
System.out.println("The animal is from: " + getRegion());
System.out.println("The animal is a: " + getType());
}
}
public static void main(String[] args) {
Lion stats = new Lion(true, "South Africa", 2, 20, false, 150);
}
}
This is a case of a nested class with one outer class and one inner class.
You will have to use the Outer class to instantiate the inner class.
Since there is no default constructor available, you will have to put value while instantiating.
Animal.Lion stats = new Animal(20, false, 150).new Lion(true, "South Africa", 2);
AnimalStats class:
public class AnimalStats {
public static void main(String[] args) {
Animal.Lion stats = new Animal(20, false, 150).new Lion(true, "South Africa", 2);
}
}
Note: This solution is with the assumption that class Animal has to be kept as is and only caller code has to be fixed.
I just need some assistance in stopping the print method. its printing my output twice as car1.print(); car2.print(); is in the print method at the bottom. how do i exclude this without deleting it. It has to be put in the super.print() part.
class Vehicle { // base class
int capacity;
String make;
Vehicle(int theCapacity, String theMake) {
capacity = theCapacity;
make = theMake;
}
void print() {
System.out.println("Vehicle Info:");
System.out.println(" capacity = " + capacity + "cc" );
System.out.println(" make = " + make );
}
}
class Car extends Vehicle {
public String type;
public String model;
public Car(int theCapacity, String theMake, String theType, String theModel) {
super(theCapacity, theMake);
type = theType;
model = theModel;
super.print();
{
System.out.println(" type = " + theType);
System.out.println(" Model = " + theModel);
}
}
}
class Task1 {
public static void main(String[] args) {
Car car1 = new Car(1200,"Holden","sedan","Barina");
Car car2 = new Car(1500,"Mazda","sedan","323");
car1.print();
car2.print();
}
}
You can use the super keyword in the constructor to invoke the super class' constructor and pass parameters to it.
Note that it must be the first statement in the constructor:
class Car extends Vehicle {
public String type;
public String model;
public Car(int theCapacity, String theMake, String theType, String theModel) {
super(theCapacity, theMake); // Here
type = theType;
model = theModel;
}
}
You are missing the Constructor
public Car (int theCapacity, String theMake, String theType, String theModel) {
capacity = theCapacity;
make = theMake;
Type = theType;
Model = theModel;
}
or
public Car (int theCapacity, String theMake, String theType, String theModel) {
super (theCapacity, theMake);
Type = theType;
Model = theModel;
}
You have to call super constructor by passing simply parameters in child class.
public Car(int capacity, String make, String type, String model) {
super(capacity, make); // simply call super
this.type = type;
this.model = model;
}
One of the solution is calling your base class Constructor from child class using super keyword and adding other parameters from child class constructor as mentioned by #Mureinik
Depending on the requirements of the Base Class you can also try using abstract methods. Example code is below.
abstract class Vehicle {
static int capacity;
static String make;
Vehicle(int theCapacity, String theMake) {
capacity = theCapacity;
make = theMake;
}
protected static void print() {
System.out.println("Vehicle Info:");
System.out.println(" capacity = " + capacity + "cc" );
System.out.println(" make = " + make );
// you can use these methods where you want in this base class.
System.out.println(" type = " + getType());
System.out.println(" model = " + getModel());
}
protected abstract String getType();
protected abstract String getModel();
}
public class Car extends Vehicle{
Car(int theCapacity, String theMake) {
super(theCapacity, theMake);
}
/**
* #param args
*/
public static void main(){
print();
}
#Override
protected String getType() {
// TODO Auto-generated method stub
return "Audi";
}
#Override
protected String getModel() {
// TODO Auto-generated method stub
return "Q7";
}
}
I need to write up a static method that takes an array of Vehicles and print each registration number in the array. The object in the array is either a Vehicle, a Car, or a Truck object reference. Finally, I need to print the registration number of the object on a single line on its own.
So the code is:
public class Vehicle {
private String registrationNumber;
public Vehicle(String rego) {
registrationNumber = rego;
}
public String getRegistrationNumber() {
return registrationNumber;
}
}
public class Car extends Vehicle {
int passengers;
public Car(String rego, int pass) {
super(rego);
passengers = pass;
}
public int getPassengers() {
return passengers;
}
}
public class Truck extends Vehicle {
int tons;
public Truck(String rego, int tons) {
super(rego);
this.tons = tons;
}
public int getTons() {
return tons;
}
}
I have to write up a static method for the following test and get the following, but I am having some trouble.
Test and expected Result
This is what I have done so far:
public static void printRegNum(Vehicle[] list){
for (int i = 0; i < list.length; i++){
System.out.println(list[i]);
}
}
The 1st way to play with your System.out.println(list[i]); is to override the toString() method in class Vehicle:
public class Vehicle {
private String registrationNumber;
public Vehicle(String rego) {
registrationNumber = rego;
}
public String getRegistrationNumber() {
return registrationNumber;
}
public String toString() {
return registrationNumber;
}
}
The 2nd way is change:
from:
System.out.println(list[i]);
to:
System.out.println(list[i].getRegistrationNumber());
Hope those can help.
Not getting where's the problem
i.e.
public static void main(String[] args){
Car car = new Car("MYCAR",4);
Truck t = new Truck("MYTRUCK", 16);
Vehicle[] myList = new Vehicle[] {car, t};
printRegNum(myList);
}
Also seems that you only need to print the "rego".
System.out.println(list[i].getRegistrationNumber());
I'm working on a task which has the following classes:
Vehicle.java ( Abstract Class)
NewVehicle.java subClass of Vehicle.java
UsedVehicle.java subClass of Vehicle.java
VehicleParser.java used as a parser
Drive Class which is used as main
In the VehicleParser class I determine which object it is. Either it is a NewVehicle object or a UsedVehicle. And in the Drive class I fill an ArrayList with the Vehicle objects.
Now When I'm trying to System.out.println an Arraylist the drive class is just invoking toString method declared in UsedVehicle/NewVehicle but not invoking the method declared in the Vehicle.java class. I need it to first invoke the method toString of Vehicle and then concat the toString of UsedVehicle/NewVehicle with it.
Here is the Code:
Vehicle
public abstract class Vehicle {
protected String make;
protected int modelYear;
protected String motivePower;
protected double licenseFee;
public Vehicle(String make,int modeYear,String motivePower) {
this.make = make;
this.modelYear= modeYear;
this.motivePower = motivePower;
this.licenseFee = 0.0;
}
public String getMake() {
return make;
}
public void setMake(String make) {
this.make = make;
}
public int getModelYear() {
return modelYear;
}
public void setModelYear(int modelYear) {
this.modelYear = modelYear;
}
public String getMotivePower() {
return motivePower;
}
public void setMotivePower(String motivePower) {
this.motivePower = motivePower;
}
public double getLicenseFee() {
return licenseFee;
}
public void setLicenseFee(double licenseFee) {
this.licenseFee = licenseFee;
}
public abstract void computeLicenseFee();
public String toString()
{
return "\nMake:\t\t"+getMake()+
"\nModel Year:\t"+getModelYear()+
"\n Motive Power:\t"+getMotivePower()+
"\nLicense Fee:\t"+getLicenseFee();
}
public static class UsedVehicle extends Vehicle
{
public String previousLicenseState;
public int currentYear;
int yearsOld = 0;
public UsedVehicle(String make, int modelYear, String power, String previousState, int currentYear)
{
super(make,modelYear,power);
this.previousLicenseState = previousState;
this.currentYear = currentYear;
}
public String getPreviousLicenseState() {
return previousLicenseState;
}
public void setPreviousLicenseState(String previousLicenseState) {
this.previousLicenseState = previousLicenseState;
}
public int getCurrentYear() {
return currentYear;
}
public void setCurrentYear(int currentYear) {
this.currentYear = currentYear;
}
public void computeLicenseFee() {
double baseFee = 100.00;
double titleTransferFee = 15.00;
double smogWaiverFee = 0.00;
double smogAbatement = 0.00;
yearsOld = getCurrentYear() - getModelYear();
if(yearsOld > 5)
{
smogWaiverFee = 8.00;
}
if("gas".equalsIgnoreCase(getMotivePower()))
{
smogAbatement = 20.00;
}
licenseFee = baseFee + smogAbatement + titleTransferFee + smogWaiverFee;
}
public String toString()
{
return "\n Years Old:\t"+yearsOld+
"\n Previous State:\t"+getPreviousLicenseState();
}
}
public static class NewVehicle extends Vehicle
{
public double vehiclePrice;
public NewVehicle(String make, int modeYear, String motivePower,double price) {
super(make, modeYear, motivePower);
this.vehiclePrice = price;
}
public double getVehiclePrice() {
return vehiclePrice;
}
public void setVehiclePrice(double vehiclePrice) {
this.vehiclePrice = vehiclePrice;
}
public void computeLicenseFee() {
double baseFee = 150.00;
double smogAbatement = 0.00;
double priceFee = 0.00;
if("gas".equalsIgnoreCase(getMotivePower()))
{
smogAbatement = 20.0;
priceFee = getVehiclePrice()*0.15;
}
licenseFee = baseFee + smogAbatement + priceFee;
}
public String toString()
{
return "Price:\t\t$"+getVehiclePrice();
}
}
}
Parser
public class VehicleParser {
public static Vehicle parseStringToVehicle(String lineToParse)
{
Vehicle vehicleObj = null;
Vehicle.UsedVehicle usedVeh = new Vehicle.UsedVehicle(make, modelYear, power, previousState, currentYear);
return vehicleObj;
}
}
DriveClass
Vehicle obj = VehicleParser.parseStringToVehicle(inputInfo);
vehicleList.add(obj);
System.out.println(vehicleList.get(i));
You are overriding the toString() method. Java doesn't do any special magic here. If you want the super class' method to be called, you need to do so explicitly with the super keyword:
#Override
public String toString()
{
return super.toString() + // Here
"\n Years Old:\t"+yearsOld+
"\n Previous State:\t"+getPreviousLicenseState();
}
Just consider this example:
public class A {
public String someMethod() {
return "A method";
}
}
public class B extends A {
#Override
public String someMethod() {
return "B method";
}
}
public class C extends B {
#Override
public String someMethod() {
return "C method";
}
}
Basically what's going on here is that when you inherit the parent class, you're overriding everything that's in parent class's method and you're giving new definition to it. By Overriding parent class's method, you're saying that:
I'm giving a new fresh definition to this method. From now onward, for all of my objects and my child's object, this is only going to be the definition that would be considered and any of parent's method definition is void.
Now if you want the parent's method definition to be called before calling this method definition, then you'd have to specifically state that using super.methodName() in your code.
public class A {
public String someMethod() {
return "A method";
}
}
public class B extends A {
#Override
public String someMethod() {
return super.someMethod() + "B method";
}
}
public class C extends B {
#Override
public String someMethod() {
return super.someMethod() + "C method";
}
}
When you call the subclass methods the overridden methods will be called and all the definitions in the parent's method will be overridden and you will get only the overridden method definition. So inprder to use the parents' method definition as well you need to use the super() method in your child class method...
return super.toString() + " is a new car!";
How would I get the instance variable hitpoints from the Dog class and pass them to the Lion Class through the method eat(X x)?
I'm trying to get the Lion to eat() the Dog and minus points from the instance variable which is stored in a new variable in the Lion Class.
Class Lion
package helloworld;
public class Lion {
public String name;
public int heightCMeters;
public int lengthCMeters;
public float weightKilos;
public int hitPoints;
public Lion(int hitPoints, String name, int heightCMeters, int lengthCMeters, float weightKilos) {
this.name = name;
this.heightCMeters = heightCMeters;
this.lengthCMeters = lengthCMeters;
this.weightKilos = weightKilos;
}
public void lionDetails() {
System.out.println("Name: " + this.name);
System.out.println("Height CM: " + this.heightCMeters);
System.out.println("Length CM: " + this.lengthCMeters);
System.out.println("Weight Kilos: " + this.weightKilos);
}
public void eat(X x) {
int hitPoints = x.hitPoints - 10;
System.out.println(x)
}
}
Class Dog
package helloworld;
public class Dog {
public String name;
public int heightCMeters;
public int lengthCMeters;
public float weightKilos;
public int hitPoints;
public Dog(int hitPoints, String name, int heightCMeters, int lengthCMeters, float weightKilos) {
this.name = name;
this.heightCMeters = heightCMeters;
this.lengthCMeters = lengthCMeters;
this.weightKilos = weightKilos;
}
public void dogDetails() {
System.out.println("Name: " + this.name);
System.out.println("Height CM: " + this.heightCMeters);
System.out.println("Length CM: " + this.lengthCMeters);
System.out.println("Weight Kilos: " + this.weightKilos);
}
public void eat(X x) {
int hitPoints = x.hitPoints - 10;
System.out.println(x)
}
}
Basically, Lions can eat dogs and the converse is true (which is weird, a dog is not brave enough to attack Lions). Anyways, what you need is an abstract class that represents animals that eat animals, this class should contain the hitPoint you mentioned.
abstract class X {
public int hitPoints;
}
// Lions are edible
class Lion extends X{
public void eat(X x) { // pass an edible object
int hitPoints = x.hitPoints - 10;
System.out.println(x)
}
}
//Dogs are edible as well
class Dog extends X{
public void eat(X x) { // pass an edible object
int hitPoints = x.hitPoints - 10;
System.out.println(x)
}
}
And now, for a Lion to a eat dog,
Lion predator = new Lion();
Dog prey = new Dog();
predators.eat(prey); // this passed dog will be eaten
Best way write a test class or write main method for Lion class which will maintain hitpoints of both the classes.
class Test{
public static void main(String[] args){
Dog puppy=new Dog(10,"Moti",12,12,31);
Lion oldLion=new Lion(20,"Old Lion",12,12,43);
oldLion.eat(puppy);
}
}
You must have an abstract class Animal, with all the common methods defined there.
For eat method of Lion class,
public void eat (Animal animal) {
this.hitPoints-=animal.hitPoints;
}
For eat method of Dog class, also the same logic.
Based on the response of sleiman jneidi:
You should create an abstract containing the hitPoints and the eat method (that it's the same behavior for each animal) Then you have not to wrote the method each time
abstract class X {
public int hitPoints;
public void eat(X x) { // pass an edible object
int hitPoints = x.hitPoints - 10;
System.out.println(x)
}
}
// Lions are edible
class Lion extends X{
}
//Dogs are edible as well
class Dog extends X{
}
The instance variable contained in the Animal class is inherited by the Lion and Dog class.
It retains the value each time the eat(Aniamal a) method is called with an Animal object passed as a parameter. So than working on the instance variable contained in the Animal object that has been passed to the eat method we can perform various functions on the instance variable.
public class Animal {
public int hitPoints;
}
public class Lion extends Animal {
public String name;
public Lion(String name) {
this.name = name;
}
public void eat(Animal a) {
a.hitPoints = a.hitPoints - 10;
System.out.println(this.name + " Has: " + a.hitPoints + " HitPoints");
}
}
public class Dog extends Animal {
public String name;
public Dog(String name) {
this.name = name;
}
public void eat(Animal a) {
a.hitPoints = a.hitPoints - 10;
System.out.println(this.name + " Has: " + a.hitPoints + " HitPoints");
}
}
public static void main(String[] args) {
Cat adam = new Cat("adam");
Lion dam = new Lion("dam");
dam.eat(adam);
}
I would make anything that can be eaten implement an interface Edible. Then that interface can have a method isEaten that takes the hit point deduction.
Something like this:
public interface Edible {
void isEaten(final int hitPointsToDeduct);
}
Then your Lion and Dog would implement this so that they could be eaten.
The Dog class would be:
public class Dog implements Edible {
public String name;
public int heightCMeters;
public int lengthCMeters;
public float weightKilos;
public int hitPoints;
public Dog(final int hitPoints, final String name, final int heightCMeters, final int lengthCMeters, final float weightKilos) {
this.name = name;
this.heightCMeters = heightCMeters;
this.lengthCMeters = lengthCMeters;
this.weightKilos = weightKilos;
}
public void dogDetails() {
System.out.println("Name: " + this.name);
System.out.println("Height CM: " + this.heightCMeters);
System.out.println("Length CM: " + this.lengthCMeters);
System.out.println("Weight Kilos: " + this.weightKilos);
}
public void eat(final Edible x) {
x.isEaten(10);
System.out.println(x);
}
public void isEaten(final int hitPointsToDeduct) {
this.hitPoints = this.hitPoints - hitPointsToDeduct;
}
}
And the Lion class:
public class Lion implements Edible {
public String name;
public int heightCMeters;
public int lengthCMeters;
public float weightKilos;
public int hitPoints;
public Lion(final int hitPoints, final String name, final int heightCMeters, final int lengthCMeters, final float weightKilos) {
this.name = name;
this.heightCMeters = heightCMeters;
this.lengthCMeters = lengthCMeters;
this.weightKilos = weightKilos;
}
public void lionDetails() {
System.out.println("Name: " + this.name);
System.out.println("Height CM: " + this.heightCMeters);
System.out.println("Length CM: " + this.lengthCMeters);
System.out.println("Weight Kilos: " + this.weightKilos);
}
public void eat(final Edible x) {
x.isEaten(10);
System.out.println(x);
}
public void isEaten(final int hitPointsToDeduct) {
this.hitPoints = this.hitPoints - hitPointsToDeduct;
}
}
The advantage of this is that the hitPoints field is held centrally to one object. The Lion is not pulling out the value of the Dogs hitPoints. Look at this page for an explanation of the "Tell Dont Ask" concept.
EDIT
Having just had a play, I noticed that you're not setting the hitPoints value in either of your constructors and that your objects print out with the object reference rather than the details. For this, override the toString method. Here's the rewritten bits of the Dog clas:
public Dog(final int hitPoints, final String name, final int heightCMeters, final int lengthCMeters, final float weightKilos) {
this.name = name;
this.heightCMeters = heightCMeters;
this.lengthCMeters = lengthCMeters;
this.weightKilos = weightKilos;
this.hitPoints = hitPoints;
}
#Override
public String toString() {
final StringBuilder builder = new StringBuilder();
builder.append("Name: ");
builder.append(this.name);
builder.append(", Height CM: ");
builder.append(this.heightCMeters);
builder.append(", Length CM: " );
builder.append(this.lengthCMeters);
builder.append(", Weight Kilos: ");
builder.append(this.weightKilos);
builder.append(", Hit Points: ");
builder.append(this.hitPoints);
return builder.toString();
}
So then with this main method:
public static void main(final String[] args) {
final Lion adam = new Lion(500, "Adam", 5, 5, 5);
final Dog fido = new Dog(500, "Fido", 5, 5, 5);
adam.eat(fido);
}
I got the following output:
Name: Fido, Height CM: 5, Length CM: 5, Weight Kilos: 5.0, Hit Points: 490
Notice the hit points have been reduced from 500 to 490.