Java Reference
In-Depth Information
// CLASS Dog
//************************************
class Dog
{
// Data specific for the Dog class
private String dogName;
private int dogLocation;
private double dogPrice;
private String dogBreed;
Pet aPet = new Pet();
// Constructor for the Dog class
public Dog(String name, int loc, double price, String race)
{
this.dogName = name;
this.dogLocation = loc;
this.dogPrice = price;
this.dogBreed = race;
}
// Overloaded methods in the Dog class
public void getName()
{
aPet.getName(this.dogName);
return;
}
public void getLocation()
{
aPet.getLocation(this.dogLocation);
return;
}
public void getPrice()
{
aPet.getPrice(this.dogPrice);
return;
}
public void getSpecData()
{
System.out.println("Dog breed :" + this.dogBreed);
return;
}
}
//******************************************
//******************************************
// Driving class
//******************************************
//******************************************
public class PetStore2
{
//*****************************
//
methods
Search WWH ::




Custom Search