Java 实验7

 /*
 * @(#)Playing
 *
 * Copyright 2008 School of Software, Yunnan University.
 *                                  All rights reserved
 */
package cn.edu.ynu.sei.Java_Labs.Lab7;

/**
 * 实验7 定义一个接口-Playing,包含有一个抽象方法
 * @version 1.0.0.0 Jan 25, 2008
 * @author eleven
 */
public interface Playing {

    abstract void play(String string);
}


/*
 * @(#)Child
 *
 * Copyright 2008 School of Software, Yunnan University.
 *                                  All rights reserved
 */
package cn.edu.ynu.sei.Java_Labs.Lab7;

/**
 * 定义一个类Child 实现Playing接口
 * @version 1.0.0.0 Jan 25, 2008
 * @author eleven
 */
public class Child implements Playing {

    public void play(String string) {
        //String string = "I am a child and I am playing a game";
        System.out.println(string);
    }
}

/*
 * @(#)Musician
 *
 * Copyright 2008 School of Software, Yunnan University.
 *                                  All rights reserved
 */
package cn.edu.ynu.sei.Java_Labs.Lab7;

/**
 * 定义一个类Musician 实现Playing接口
 * @version 1.0.0.0 Jan 25, 2008
 * @author eleven
 */
public class Musician implements Playing {

    public void play(String string) {
        //String string = " I am a musician and I am playing a song";
        System.out.println(string);
    }
}


/*
 * @(#)Actor
 *
 * Copyright 2008 School of Software, Yunnan University.
 *                                  All rights reserved
 */
package cn.edu.ynu.sei.Java_Labs.Lab7;

/**
 * 定义一个类Actor 实现Playing接口
 * @version 1.0.0.0 Jan 25, 2008
 * @author eleven
 */
public class Actor implements Playing {

    public void play(String string) {
        //String string = " I am an actor and I am playing a part";
        System.out.println(string);
    }
}



/*
 * @(#)UsePlaying
 *
 * Copyright 2008 School of Software, Yunnan University.
 *                                  All rights reserved
 */
package cn.edu.ynu.sei.Java_Labs.Lab7;

/**
 * 使用其他三个类
 * @version 1.0.0.0 Jan 25, 2008
 * @author eleven
 */
public class UsePlaying {

    public static void main(String[] args) {
        Child child = new Child();
        Musician musician = new Musician();
        Actor actor = new Actor();

        child.play("I am a child and I am playing a game");
        musician.play("I am a musician and I am playing a song");
        actor.play("I am an actor and I am playing a part");
    }
}



------------------
测试
/*
 * @(#)ActorTest
 *
 * Copyright 2008 School of Software, Yunnan University.
 *                                  All rights reserved
 */
package cn.edu.ynu.sei.Java_Labs.Lab7;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 * 类Actor测试用例
 * @version 1.0.0.0 Jan 27, 2008
 * @author eleven
 */
public class ActorTest {

    public ActorTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of play method, of class Actor.
     */
    @Test
    public void play() {
        System.out.println("play");
        String string = "ActorTest";
        Actor instance = new Actor();
        instance.play(string);
    }
}

/*
 * @(#)ChildTest
 *
 * Copyright 2008 School of Software, Yunnan University.
 *                                  All rights reserved
 */
package cn.edu.ynu.sei.Java_Labs.Lab7;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 * 类Child测试用例
 * @version 1.0.0.0 Jan 27, 2008
 * @author eleven
 */
public class ChildTest {

    public ChildTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of play method, of class Child.
     */
    @Test
    public void play() {
        System.out.println("play");
        String string = "ChildTest";
        Child instance = new Child();
        instance.play(string);
    }
}


/*
 * @(#)MusicianTest
 *
 * Copyright 2008 School of Software, Yunnan University.
 *                                  All rights reserved
 */
package cn.edu.ynu.sei.Java_Labs.Lab7;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 * 类Musician测试用例
 * @version 1.0.0.0 Jan 27, 2008
 * @author eleven
 */
public class MusicianTest {

    public MusicianTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of play method, of class Musician.
     */
    @Test
    public void play() {
        System.out.println("play");
        String string = "MusicianTest";
        Musician instance = new Musician();
        instance.play(string);
    }
}



/*
 * @(#)PlayingTest
 *
 * Copyright 2008 School of Software, Yunnan University.
 *                                  All rights reserved
 */
package cn.edu.ynu.sei.Java_Labs.Lab7;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 * 接口Playing 测试用例 有问题,待改正
 * @version 1.0.0.0 Jan 27, 2008
 * @author eleven
 */
public class PlayingTest {

    private Playing instance;

    public PlayingTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of play method, of class Playing.
     */
    @Test
    public void play() {
        System.out.println("play");
        String string = "hello";
        //instance.play(string);
    }
}



/*
 * @(#)UsePlayingTest
 *
 * Copyright 2008 School of Software, Yunnan University.
 *                                  All rights reserved
 */
package cn.edu.ynu.sei.Java_Labs.Lab7;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 * UsePlaying测试用例
 * @version 1.0.0.0 Jan 27, 2008
 * @author eleven
 */
public class UsePlayingTest {

    public UsePlayingTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of main method, of class UsePlaying.
     */
    @Test
    public void main() {
        System.out.println("main");
        String[] args = null;
        UsePlaying.main(args);
    }
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值