Console.java 965B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import java.util.Scanner;
  2. public class Console
  3. {
  4. int numberOfPets;
  5. String typeOfPet;
  6. String nameOfPet;
  7. Pet pet = new Pet();
  8. public Console()
  9. {
  10. }
  11. public int inputNumberOfPets(){
  12. Scanner scanner = new Scanner(System.in);
  13. System.out.println("Enter number of pets.");
  14. return scanner.nextInt();
  15. }
  16. public String inputTypeOfPet(){
  17. Scanner scanner = new Scanner(System.in);
  18. System.out.println("Enter type of pet.");
  19. return scanner.nextLine();
  20. }
  21. public String inputNameOfPet(){
  22. Scanner scanner = new Scanner(System.in);
  23. System.out.println("Enter name of pet.");
  24. return scanner.nextLine();
  25. }
  26. public void printPetInfo(Pet[] petArray){
  27. for(Pet element: petArray){
  28. System.out.println(element.getNameOfPet()+" is a "+element.getTypeOfPet()+" and says "+element.speak());
  29. }
  30. }
  31. }