A pet can either be a cat or a dog. Each pet needs to have a name, an owner’s name, color, doctor’s name and breed. All of the pets can cry, eat and sleep. Without using the switch method, I tried to use setter and getter function with scanner. but i dont know how to identify if the user inputs dog then the user will input all about the dog then else the cat.
is this possible?
package petexercise;
import java.util.Scanner;
public class PetCatDog {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
PetCat cat = new PetCat();
PetDog dog = new PetDog();
System.out.print("Enter Dog or Cat Word:");
String pet = cat.nextLine();
}
}
the other subclasses are made for the setter and getters