Abstract class Pet has an array of Dose objects, as well as a subclass Dog
When I try to compile Dog.java, the first error i get (the problem I need the most help with) is:
Dog.java:5: cannot find symbol
symbol : constructor Pet()
location: class Pet
public class Dog extends Pet
^
I'm sorry if the answer can be found elsewhere in the forums, I've had a bit of a look, but havent seen (or at least recognised) the help i need
My code so far:
Pet.java:
CODE
public abstract class Pet
{
private String name;
private double weight;
private Date dob;
private double accumulatedDose;
public Pet(String nameIn, double weightIn, Date dobIn, double accumulatedDoseIn)
{
this.name = nameIn;
this.weight = weightIn;
this.dob = dobIn;
this.accumulatedDose = accumulatedDoseIn;
}
public abstract double getDose(double weight);
public int getAgeInMonths(Date d)
{
Date now = new Date();
int nowYear = now.getYear();
int nowMonth = now.getMonth();
int thenYear = d.getYear();
int thenMonth = d.getMonth();
int yearDiff = nowYear-thenYear;
int monthDiff = nowMonth-thenMonth;
int ageInMonths = yearDiff*12 + monthDiff;
return ageInMonths;
}
}
Dog.java:
CODE
public class Dog extends Pet
{
private String breed;
public double getDose(double weightIn)
{
int age;
Date dob = super.dob;
double doseInMilligrams;
age = super.getAgeInMonths(dob);
if (ageInMonths < 3)
doseInMilligrams = 0;
else if (ageInMonths > 12 && weight < 2)
doseInMilligrams = 6 + 0.75*weight;
else
doseInMilligrams = 12 + 0.65*weight;
}
}
and Dose.java:
CODE
public class Dose
{
private String nameOfDrug;
private Date date;
private double doseInGrams;
public Dose(String nameOfDrugIn, Date dateIn, double doseInGramsIn)
{
nameOfDrug = nameOfDrugIn;
date = dateIn;
doseInGrams = doseInGramsIn;
}
public double getDose()
{
return doseInGrams;
}
public Date getDate()
{
return date;
}
public String toString()
{
return nameOfDrug;
}
}
I realise that so far, most of my classes are incomplete, but any help and the pointing out of any mistakes so far would be appreciated.
Thanks
This post has been edited by Khazidhea: 24 May, 2007 - 04:10 AM