クラス一覧 名前 説明 Dog 犬を表すクラス(作成済み) DogSearchMain 犬の探索を行う ○ DogSearchMain クラス 【main メソッド】 1. 下記ペット表のようなDog の配列を作成する。 2. 標準入力から、探索対象の犬の年齢を入力する。 3. 探索対象が見つかった場合はその犬の情報を show()メソッド、showInoculation()メソッドで表示し、 見つからなかった場合は「見つかりませんでした。」 と表示する。 ペット表 名前 年齢 予防接種 ポチ 1 未接種 ラッキー 2 接種済み チョコ 3 接種済み 小太郎 2 未接種
class Dog { private String name; private int age; private boolean inoculation; public Dog(String name, int age, boolean inoculation) { this.name = name; this.age = age; this.inoculation = inoculation; } public int getAge() { return this.age; } public String show() { String str = String.format("%s は %d 歳です。", this.name, this.age); return str; } public String showInoculation() { String str; if (this.inoculation) { str = "予防接種済みです。"; } else { str = "未予防接種です。"; } return str; } } class DogSearchMain { public static void main(String[] args) { Dog[] dogs = {