码迷,mamicode.com
首页 > 编程语言 > 详细

Java实验题3_5_林大锐格平台

时间:2017-04-09 00:37:58      阅读:293      评论:0      收藏:0      [点我收藏+]

标签:log   ted   .sh   owb   ext   java   out   stat   end   

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_林大锐格平台

标签:log   ted   .sh   owb   ext   java   out   stat   end   

原文地址:http://www.cnblogs.com/lijunzone/p/6683249.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!