package zh.codegym.task.task07.task0726;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Cat 代码将无法编译
*/
public class Solution {
static ArrayList<Cat> CATS = new ArrayList<Cat>();
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while (true) {
String name = reader.readLine();
if (name.isEmpty())
{
break;
}
else{
int age=Integer.parseInt(reader.readLine());
int weight=Integer.parseInt(reader.readLine());
int tailLength=Integer.parseInt(reader.readLine());
Cat cat = new Cat(name,age,weight,tailLength);
CATS.add(cat);
}
}
printList();
}
public static void printList() {
for(int i=0;i<CATS.size();i++)
{
System.out.println(CATS.get(i));
}
}
public static class Cat {
private String name;
private int age;
private int weight;
private int tailLength;
public Cat(String name, int age, int weight, int tailLength) {
this.name = name;
this.age = age;
this.weight = weight;
this.tailLength = tailLength;
}
@Override
public String toString() {
return "猫的名字:" + name + ",年龄:" + age + ",体重:" + weight + ",尾巴:" + tailLength;
}
}
}
package zh.codegym.task.task07.task0726;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Cat 代码将无法编译
*/
public class Solution {
static ArrayList<Cat> CATS = new ArrayList<Cat>();
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while (true) {
String name = reader.readLine();
if (name.isEmpty())
{
break;
}
else{
int age=Integer.parseInt(reader.readLine());
int weight=Integer.parseInt(reader.readLine());
int tailLength=Integer.parseInt(reader.readLine());
Cat cat = new Cat(name,age,weight,tailLength);
CATS.add(cat);
}
}
printList();
}
public static void printList() {
for(int i=0;i<CATS.size();i++)
{
System.out.println(CATS.get(i));
}
}
public static class Cat {
private String name;
private int age;
private int weight;
private int tailLength;
public Cat(String name, int age, int weight, int tailLength) {
this.name = name;
this.age = age;
this.weight = weight;
this.tailLength = tailLength;
}
@Override
public String toString() {
return "猫的名字:" + name + ",年龄:" + age + ",体重:" + weight + ",尾巴:" + tailLength;
}
}
}