Java实验题3_5_林大锐格平台
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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_林大锐格平台的主要内容,如果未能解决你的问题,请参考以下文章