I have to make a program which is supposed to receive an input for pet information and output it in a specific way.
Normally this would be a cake and take 10 minutes, but we just moved into OOP and I am having some trouble figuring out what to put in the mutator on the driver.
Driver:
import java.util.HashSet;
import java.util.Set;
public class JMPets {
private String petType;
private String petName;
private int petAge;
private double petWeight;
boolean isMale;
public void setType(String petType)
{
this.petType = petType;
}
public void setName(String petName)
{
this.petName = petName;
}
public void setAge (int petAge)
{
this.petAge = petAge;
}
public void setWeight(double petWeight)
{
this.petWeight = petWeight;
}
public String getType()
{
return petType;
}
public String getName()
{
return petName;
}
public int getAge()
{
return petAge;
}
public double getWeight()
{
return petWeight;
}
public void set(String petType, String petName, int petAge,
double petWeight)
{
//WHAT DO I PUT HERE
}
}
import java.util.Scanner;
public class JMUnit6 {
public static void main(String[] args) {
JMPets myPet1 = new JMPets();
JMPets myPet2 = new JMPets();
JMPets mypet3 = new JMPets();
Scanner stdIn = new Scanner(System.in);
System.out.println("Welcome to the Java Pet Tracker");
System.out.println("Please enter the type of Pet #1:");
String petType = stdIn.nextLine();
System.out.println("Please enter the name of Pet #1:");
String petName = stdIn.nextLine();
System.out.println("Please enter the age of " +petName+":");
int petAge = stdIn.nextInt();
System.out.println("Please enter the weight of "+petName+":");
double petWeight = stdIn.nextDouble();
System.out.println("Is "+petName+" Male?:");
boolean isMale = stdIn.nextBoolean();
myPet1.set(petType, petName, petAge, petWeight);
System.out.println(myPet1.getType());
System.out.println(myPet1.getName());
System.out.println(myPet1.getAge());
System.out.println(myPet1.getWeight());
}//end main
}//end class JMUnit6
The only output I get is null null 0 0.0.