首页 > 代码库 > 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_林大锐格平台