* @(#)Auto
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_2;
/**
* 实验6 第二个Auto抽象类
* @version 1.0.0.0 Jan 25, 2008
* @author eleven
*/
public abstract class Auto {
private String make;
private double price;
public String getMake() {
return make;
}
public void setMake(String make) {
this.make = make;
}
public double getPrice() {
return price;
}
public abstract void setPrice(double price);
}
/*
* @(#)Chevy
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_2;
/**
* 实验6 第二个 Chevy牌
* @version 1.0.0.0 Jan 25, 2008
* @author eleven
*/
public class Chevy extends Auto {
@Override
public void setPrice(double price) {
System.out.println("A new Chevy costs $" + price);
}
}
/*
* @(#)Ford
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_2;
/**
* 实验6 第二个 Ford牌
* @version 1.0.0.0 Jan 25, 2008
* @author eleven
*/
public class Ford extends Auto {
@Override
public void setPrice(double price) {
System.out.println("A new Ford costs $" + price);
}
}
/*
* @(#)UseAuto
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_2;
/**
* 实验6 第二个 使用其他三个类
* @version 1.0.0.0 Jan 25, 2008
* @author eleven
*/
public class UseAuto {
private Auto auto;
public static void main(String[] args) {
Ford ford = new Ford();
Chevy chevy = new Chevy();
ford.setPrice(20000);
chevy.setPrice(22000);
}
}
------------------
测试/*
* @(#)AutoTest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_2;
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.*;
/**
*
* @version 1.0.0.0 Jan 25, 2008
* @author eleven
*/
public class AutoTest {
public AutoTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of getMake method, of class Auto.
*/
@Test
public void getMake() {
System.out.println("getMake");
//Auto instance = new Auto();
String expResult = "";
//String result = instance.getMake();
//assertEquals(expResult, result);
}
/**
* Test of setMake method, of class Auto.
*/
@Test
public void setMake() {
System.out.println("setMake");
String make = "";
//Auto instance = new Auto();
// instance.setMake(make);
}
/**
* Test of getPrice method, of class Auto.
*/
@Test
public void getPrice() {
System.out.println("getPrice");
// Auto instance = new Auto();
double expResult = 0.0;
//double result = instance.getPrice();
//assertEquals(expResult, result);
}
/**
* Test of setPrice method, of class Auto.
*/
@Test
public void setPrice() {
System.out.println("setPrice");
double price = 0.0;
//Auto instance = new Auto();
//instance.setPrice(price);
}
}
/*
* @(#)ChevyTest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_2;
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.*;
/**
*
* @version 1.0.0.0 Jan 25, 2008
* @author eleven
*/
public class ChevyTest {
public ChevyTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of setPrice method, of class Chevy.
*/
@Test
public void setPrice() {
System.out.println("setPrice");
double price = 10.0;
Chevy instance = new Chevy();
instance.setPrice(price);
}
}
/*
* @(#)FordTest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_2;
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.*;
/**
*
* @version 1.0.0.0 Jan 25, 2008
* @author eleven
*/
public class FordTest {
public FordTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of setPrice method, of class Ford.
*/
@Test
public void setPrice() {
System.out.println("setPrice");
double price = 20.0;
Ford instance = new Ford();
instance.setPrice(price);
}
}
/*
* @(#)UseAutoTest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_2;
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.*;
/**
*
* @version 1.0.0.0 Jan 25, 2008
* @author eleven
*/
public class UseAutoTest {
public UseAutoTest() {
}
@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 UseAuto.
*/
@Test
public void main() {
System.out.println("main");
String[] args = null;
UseAuto.main(args);
}
}