首页 > 代码库 > Java实验题3_5_林大锐格平台
Java实验题3_5_林大锐格平台
import java.util.Scanner; //write code here class Dog{ String breed,color;int weight; } class SpottedDog extends Dog{ private String spotColor; SpottedDog(String a,int b,String c,String d){ breed=a;weight=b;color=c;spotColor=d; } void showBreed(){ System.out.println(breed); } void spotInfo(){ System.out.println(spotColor); } } class UnspottedDog extends Dog{ UnspottedDog(String a,int b,String c){ breed=a;weight=b;color=c; } void showBreed(){ System.out.println(breed); } } public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String str1 = scan.next(); int age1 = scan.nextInt(); String str2 = scan.next(); String str3 = scan.next(); String str4 = scan.next(); int age2 = scan.nextInt(); String str5 = scan.next(); SpottedDog redSpot = new SpottedDog(str1,age1, str2, str3); UnspottedDog rover = new UnspottedDog(str4, age2, str5); redSpot.showBreed(); redSpot.spotInfo(); rover.showBreed(); } }
Java实验题3_5_林大锐格平台
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。