How can I override a method in a base class without using the @Override sign? For example the class Human below overrides some methods in the class Mammal. Do print the output correctly without @ signs in objects. Convert them correctly before outputting.
import java.util.*;
public abstract class Human extends Mammal
{
int MyAge,Age;
String mrating;
Arms[] arms = new Arms[2];
Leg[] legs = new Leg[2];
void walk()
{
legs[0].move("Right Leg");
legs[1].move("Left Leg");
}
void swim()
{
arms[0].move("Right hand");
arms[1].move("Left hand");
}
// default constructor
public Human(String name)
{
super(name);
gender = 'M'; // the default is M for Male
}
@Override
public void makeSound()
{
System.out.print(name+" Oooops ");
}
@Override
public void getOlder(int years)
{
age += years;
}
@Override
public void eat()
{
System.out.print("Some food please...");
}
// the getters and setters...
public int getAge()
{
return this.MyAge;
}
public void setAge(int Age)
{
this.MyAge=Age;
}
//methods for iterating through the limbs
public void getArms()
{
Limb limbs = new Arms("");
ArrayList myArms = new ArrayList();
// Populate the list using the .add() methods
myArms.add("Right Hand");
myArms.add("Left Hand");
Collection myforeLimbs =myArms;
if(limbs instanceof Arms)
{
System.out.println("\t"+myforeLimbs);
}
}
public void getLegs()
{
Limb limbs = new Leg("");
ArrayList myLegs = new ArrayList();
// Populate the list using the .add() methods
myLegs.add("Right Leg");
myLegs.add("Left Leg");
Collection myhindLimbs =myLegs;
if(limbs instanceof Leg)
{
System.out.println("\t"+myhindLimbs);
}
}
public abstract boolean canWatchMovie(String mRt);
}