私はあなたのためにそれを試みるつもりはありませんが、このような問題で使用できるヒントは、このような情報を表すクラスを作成できるということです。あなたの質問では、あなたは配列を使いたいです。あなたの質問にobjectというタグを付けました。すべての
まず、各段階で、あなたのようなものを見ることができますAnimal
オブジェクトを作成することができ、行ごとにテキストファイルを読むことができます:
class Animal {
private String name;
private int feet;
private boolean tail, dangerous;
private String color;
public Animal(){
}
public Animal(String name, int feet, boolean tail, boolean dangerous, String color){
this.name = name;
this.feet = feet;
this.tail = tail;
this.dangerous = dangerous;
this.color = color;
}
// getters and setters for these fields here
}
あなたは、このテキストファイルから多くの動物を持っているので、
ArrayList<Animal> animals = new ArrayList<>();
for(each line of the textfile you read){
animals.add(new Animal(...));
}
これは配列が役立つ部分です。
コードを投稿する必要があります。私たちはあなたのためにそれを書くつもりはありません。 –
質問にあなたが試したコードと予想される結果を含めてください – CraigR8806