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();
}
}