1
0

More than 1 year has passed since last update.

abscract classを使ったプログラム

Posted at

abctract classを使った糸魚川市のプログラムです。

package itoigawa;
import java.util.Scanner;



abstract class ItoigawaCity{
    void ItoigawaCity() {}
}

class ItoigawaRikyu extends ItoigawaCity {
    private String city = "糸魚川市";
    void ItoigawaCity() {
        System.out.println(city);
    }
    void ItoigawaRikyu() {
        String shop_name="糸魚川利休";
        System.out.println(shop_name);
    }
    void SetItoigawa(String s) {
        if (s.equals(city)== true) {
            this.city = s;
        } else {
            this.city = city;
        }

    }
    String GetItoigawa() {
        return this.city;
    }
}

public class Itoigawa2 {
    public static void main(String[] args) {
        ItoigawaRikyu ir = new ItoigawaRikyu();
        Scanner sc = new Scanner(System.in);
        System.out.println("糸魚川利休のある市はどこでしょう?");
        String shop_name2 = sc.nextLine();
        ir.ItoigawaCity();
        ir.ItoigawaRikyu();
        ir.SetItoigawa(shop_name2);
        String ans = ir.GetItoigawa();
        System.out.println(ans);
        sc.close();

    }
}
1
0
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0