首页 > 代码库 > 星期四的收获

星期四的收获

package com.chainsoft.lianxi.AM;
import java.util.Calendar;


public class Xiaogushi {
	 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Laomao mao = new Laomao();
		mao.Cat2();
		mao.Cat3();
		mao.Cat4();
		mao.Cat5();
		mao.Cat6();
		Laomao mao1 = new Xiaomao();
		System.out.print(((Xiaomao)mao1).Cat7());
		 double a = Math.random();
			int dice = (int)(4*a+1);
			System.out.print(dice);
		System.out.print(((Xiaomao) mao1).Cat8());
		((Xiaomao) mao1).Cat9();
		double b = Math.random();
		int dice1 = (int)(100*b+80);
		System.out.print(dice1);
		((Xiaomao) mao1).Cat10();
		Calendar c = Calendar.getInstance();
		int year = c.get(Calendar.YEAR); 
		int month = c.get(Calendar.MONTH)+1; 
		int date = c.get(Calendar.DATE); 
//		int hour = c.get(Calendar.HOUR_OF_DAY); 
//		int minute = c.get(Calendar.MINUTE); 
//		int second = c.get(Calendar.SECOND); 
System.out.print(year +"-" + month + "-" + date ); 
         ((Xiaomao) mao1).Cat11();
	}

}
 class Laomao{ 
	 String name = "Tom";
	 String color = "黑色";
	 String sex = "母";
	 int age = 3;
	 void Cat2(){
		 System.out.print("  从前有只"+age+"岁的叫"+name+"的"+sex+"猫,它的颜色很"+color+"。");
	 }
	void Cat3(){
    	 System.out.print("它在经过了无数次了失恋后,遇到了同样失恋的猴子。");
     }
	 void Cat4(){
		 System.out.println("他们相互慰藉彼此受伤的心灵,慢慢的产生了感情。");
	 }
	 void Cat5(){
		 System.out.print("但是迫于物种的差异让他们不能在一起,于是他们在各自的种族找了一个迷惑的对象。");
	 }
	 void Cat6(){ 
		 System.out.println("日久生情,假的变成了真的,真的却慢慢的淡忘了。");
	 } 
 }
 class Xiaomao extends Laomao{
	 Xiaomao(){
		 super();
	 }
	 String Cat7(){
		
		 return "    几年后,它的";
	 }
	 String Cat8(){
		 return "个孩子出生了,它的颜色和它母亲一样是"+color+"的,性别也一样是"+sex+"的。";
	 }
	 void Cat9(){
		 System.out.print("小猫咪很可爱,刚出生就有");
	 }
	 void Cat10(){
		 System.out.print("g了,");
		 System.out.print("100天后,小猫离开了自己的父母,独自求生。");
		 System.out.println("在");
	 }
	 void Cat11(){
		 System.out.print("这天,");
		 System.out.print("这只小猫刚吃完自己抓的老鼠,悠闲地舔着水喝,");
		 System.out.println("然后去推球玩。这时一条狗看到了推球玩的小猫,于是跑去追猫咬,追着追着两个心心相惜,产生了感情,");
		 System.out.print("于是一起生活在了一起。2年后,这只猫咪发现爱犬和隔壁的泰迪发生了关系,");
		 System.out.print("伤心欲绝之下跳水自杀,爱犬为了救爱猫学会了游泳。自此之后,猫怕水,狗会游泳。");
	 }
 }
 

  输出结果为技术分享

星期四的收获