Question: Consider the class Cat. It has a kind(String) and a age(int). It has an initialization constructor, a default constructor, setters and getters, and a toString()
Consider the class Cat. It has a kind(String) and a age(int). It has an initialization constructor, a default constructor, setters and getters, and a toString() method. Assume this class is given (i.e. do not write the class methods).
Write a method readCats(String inputFileName) that does the following:
1. opens the input file name for reading
2. Reads the the kind and the age of each cat in the file
3. creates an object of type Cat and fills it with the read information
4. then displays this object using the toString() method of the class Cat.
5. Handel all possible exceptions
Sample input file
Persian 3
Egyptian 2
Siamese 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
