Hi everyone I have a issue where I have written the entire program but couple little tweaks are needed for me to get the program done.
I have my super class here "Pet". I have created couple objects in Main, "myRobin" , "myCow", "myBlackMamba" and passed some arguments to them. Im now trying to send those parameters and have them printed to the output via the toString method I have. Im learning my way around Java ..so Im wondering what am I missing that could make this possible....
Thanks everyone.
public class Pet
{
//office wants to store info regarding the animal it treats
/*
* Done
*/
///variables
/*Diet
* Nocturnal
* poisionous
* ability to fly
*/
/*
* Done
*/
//Classes
/*SuperClass pet
* subClass:
* robin, cow, black mamaba
*/
/*
* Done
*/
///Characteristics
/*Num. of Legs
* wings or no
* feathers , skin or fur
* nocturnal
*/
private int numOfLegs;
private String wings;
private String skin;
private String fur;
private String nocturnal;
private String diet;
private String poison;
public Pet(int l , String w , String s, String n, String d, String p)
{
numOfLegs = l;
wings = w;
skin = s;
nocturnal = n;
diet = d;
poison = p;
}
//will allow me to create subclasses
public Pet()
{
}
//main start
public static void Main(String[] args)
{
//return what each different class does
Robin myRobin = new Robin(2, "Two Wings" , "feathers" , "No I sleep" , "berries" , "I am not poisonous!" );
myRobin.toString();
Cow myCow = new Cow(4,"No Wings", "little fur" , "I sleep, moo!", "I love to eat hay and grass", "Im not poisionous :(");
myCow.toString();
BlackMamba myBlackMamba = new BlackMamba(0, "No Wings","skin","awake at night","I love eating rodents","Of course Im poisonous");
myBlackMamba.toString();
Pet p = new Pet();
}
//might delete this
public void Report()
{
System.out.println("This is the information for the pet.");
}
///Generate getters and setters to access private data fields
public String getWings() {
return wings;
}
public void setWings(String wings) {
this.wings = wings;
}
public String getSkin() {
return skin;
}
public void setSkin(String skin) {
this.skin = skin;
}
public String getFur() {
return fur;
}
public void setFur(String fur) {
this.fur = fur;
}
public String getNocturnal() {
return nocturnal;
}
public void setNocturnal(String nocturnal) {
this.nocturnal = nocturnal;
}
public String getDiet() {
return diet;
}
public void setDiet(String diet) {
this.diet = diet;
}
public String getPoison() {
return poison;
}
public void setPoison(String poison) {
this.poison = poison;
}
public void setNumOfLegs(int numOfLegs) {
this.numOfLegs = numOfLegs;
}
public int getNumOfLegs()
{
return numOfLegs;
}
////end getters and setters
public String toString()
{
return("Robin:" + wings );
}
///Test all subclasses.
//start with
}
and then my other three classes "Robin, Cow, BlackMamba" . Since these three subclasses are pretty much similar except for the names I will post the Robin class here:
package com.Java.CS300;
public class Robin extends Pet
{
///Determine whether this constructor is needed
public Robin(int l , String w , String s, String n, String d, String p)
{
}
//myPet is of type "Pet"
public Pet myPet;
///list the characteristics here and return a message which concludes what the animal does
//these are the methods supplied to the animal
public void Legs(Pet p)
{
myPet = p;
}
public Pet doIFly()
{
return myPet;
}
public Pet mySkin()
{
return myPet;
}
public Pet poison()
{
return myPet;
}
public Pet nocturnal()
{
return myPet;
}
public Pet diet()
{
return myPet;
}
//method for animal to report its characteristics
////might delete this
public void infoRobin(int l , String w , String f, String s, String n, String d, String p)
{
//call from main Robin object
} // end of report on Robin
}