/*
* @(#)CollegeCourse
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_1;
/**
* 实验6 计算课程费用
* 在本程序中假设只有4门课程,分别为:1 Java;2 J2EE ; 3 操作系统 ; 4 IT市场营销
* 其学分分别为 3 3 4 2
* 而对于总的课程费用,为了便于检查结果的正确性,在程序中假设的是1200美元
* 课程费用计算采用的是 “(1000/12)*单课课程学分" 的方式
* @version 1.0.0.0 Jan 24, 2008
* @author eleven
*/
public class CollegeCourse {
/**
* 根据课程学分计算该课程的费用
*/
public double CollegeCourse(double courseCount) {
double result = (1200 / 12) * courseCount;
return result;
}
/**
* 根据课程编号得到该课程的学分数
*/
public int FindCourseCountFeeByID(int courseId) {
if (courseId == 1) {
System.out.println("This is the Java Course");
return 3;
}
if (courseId == 2) {
System.out.println("This is the J2EE Course");
return 3;
}
if (courseId == 3) {
System.out.println("This is the Operating System Course");
return 4;
}
if (courseId == 4) {
System.out.println("This is the IT Marketing Course");
return 2;
}
return -1;
}
}
/*
* @(#)Lab
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_1;
/**
* 实验6 计算课程实验费用
* 在本程序的计算中假设每门课程都有实验,而每门课实验的费用计算方法为 “课程学分*5“
* 在总课程的实验费用方面一共是12*5 = 60 美元
* @version 1.0.0.0 Jan 24, 2008
* @author eleven
*/
public class Lab {
/**
* 计算课程的实验费用
*/
public double Lab(int courseCount) {
double labResult = courseCount * 5;
return labResult;
}
}
/*
* @(#)UseCourse
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_1;
/**
* 实验6 使用CollegeCourse 和 Lab
* 声明:本程序课程总费用为1200美元
* 本程序的所有课程总费用为60美元,与课程总费用无关
* 每门课的总费用 = 课程费用+实验费用
* @version 1.0.0.0 Jan 24, 2008
* @author eleven
*/
public class UseCourse {
public static void main(String[] args) {
CollegeCourse collegeCourse = new CollegeCourse();
Lab lab = new Lab();
int courseCount = collegeCourse.FindCourseCountFeeByID(4);
double collegeCourseFee = collegeCourse.CollegeCourse(courseCount);
double labFee = lab.Lab(courseCount);
System.out.println("The cost of your class is $" + collegeCourseFee + ",");
System.out.println("there is a $" + labFee + " lab fee.");
double sumFee = collegeCourseFee + labFee;
System.out.println("The cost of your course is $" + sumFee + ".");
}
}
------------------------
测试
/*
* @(#)CollegeCourseTest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_1;
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 24, 2008
* @author eleven
*/
public class CollegeCourseTest {
public CollegeCourseTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of CollegeCourse method, of class CollegeCourse.
*/
@Test
public void CollegeCourse() {
System.out.println("CollegeCourse");
double courseCount = 3.0;
CollegeCourse instance = new CollegeCourse();
double expResult = 300.0;
double result = instance.CollegeCourse(courseCount);
assertEquals(expResult, result);
}
/**
* Test of FindCourseCountFeeByID method, of class CollegeCourse.
*/
@Test
public void FindCourseCountFeeByID() {
System.out.println("FindCourseCountFeeByID");
int courseId = 1;
CollegeCourse instance = new CollegeCourse();
int expResult = 3;
int result = instance.FindCourseCountFeeByID(courseId);
assertEquals(expResult, result);
}
}
/*
* @(#)LabTest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_1;
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 24, 2008
* @author eleven
*/
public class LabTest {
public LabTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of Lab method, of class Lab.
*/
@Test
public void Lab() {
System.out.println("Lab");
int courseCount = 3;
Lab instance = new Lab();
double expResult = 15.0;
double result = instance.Lab(courseCount);
assertEquals(expResult, result);
}
}
/*
* @(#)UseCourseTest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_1;
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 24, 2008
* @author eleven
*/
public class UseCourseTest {
public UseCourseTest() {
}
@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 UseCourse.
*/
@Test
public void main() {
System.out.println("main");
String[] args = null;
UseCourse.main(args);
}
}
* @(#)CollegeCourse
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_1;
/**
* 实验6 计算课程费用
* 在本程序中假设只有4门课程,分别为:1 Java;2 J2EE ; 3 操作系统 ; 4 IT市场营销
* 其学分分别为 3 3 4 2
* 而对于总的课程费用,为了便于检查结果的正确性,在程序中假设的是1200美元
* 课程费用计算采用的是 “(1000/12)*单课课程学分" 的方式
* @version 1.0.0.0 Jan 24, 2008
* @author eleven
*/
public class CollegeCourse {
/**
* 根据课程学分计算该课程的费用
*/
public double CollegeCourse(double courseCount) {
double result = (1200 / 12) * courseCount;
return result;
}
/**
* 根据课程编号得到该课程的学分数
*/
public int FindCourseCountFeeByID(int courseId) {
if (courseId == 1) {
System.out.println("This is the Java Course");
return 3;
}
if (courseId == 2) {
System.out.println("This is the J2EE Course");
return 3;
}
if (courseId == 3) {
System.out.println("This is the Operating System Course");
return 4;
}
if (courseId == 4) {
System.out.println("This is the IT Marketing Course");
return 2;
}
return -1;
}
}
/*
* @(#)Lab
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_1;
/**
* 实验6 计算课程实验费用
* 在本程序的计算中假设每门课程都有实验,而每门课实验的费用计算方法为 “课程学分*5“
* 在总课程的实验费用方面一共是12*5 = 60 美元
* @version 1.0.0.0 Jan 24, 2008
* @author eleven
*/
public class Lab {
/**
* 计算课程的实验费用
*/
public double Lab(int courseCount) {
double labResult = courseCount * 5;
return labResult;
}
}
/*
* @(#)UseCourse
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_1;
/**
* 实验6 使用CollegeCourse 和 Lab
* 声明:本程序课程总费用为1200美元
* 本程序的所有课程总费用为60美元,与课程总费用无关
* 每门课的总费用 = 课程费用+实验费用
* @version 1.0.0.0 Jan 24, 2008
* @author eleven
*/
public class UseCourse {
public static void main(String[] args) {
CollegeCourse collegeCourse = new CollegeCourse();
Lab lab = new Lab();
int courseCount = collegeCourse.FindCourseCountFeeByID(4);
double collegeCourseFee = collegeCourse.CollegeCourse(courseCount);
double labFee = lab.Lab(courseCount);
System.out.println("The cost of your class is $" + collegeCourseFee + ",");
System.out.println("there is a $" + labFee + " lab fee.");
double sumFee = collegeCourseFee + labFee;
System.out.println("The cost of your course is $" + sumFee + ".");
}
}
------------------------
测试
/*
* @(#)CollegeCourseTest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_1;
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 24, 2008
* @author eleven
*/
public class CollegeCourseTest {
public CollegeCourseTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of CollegeCourse method, of class CollegeCourse.
*/
@Test
public void CollegeCourse() {
System.out.println("CollegeCourse");
double courseCount = 3.0;
CollegeCourse instance = new CollegeCourse();
double expResult = 300.0;
double result = instance.CollegeCourse(courseCount);
assertEquals(expResult, result);
}
/**
* Test of FindCourseCountFeeByID method, of class CollegeCourse.
*/
@Test
public void FindCourseCountFeeByID() {
System.out.println("FindCourseCountFeeByID");
int courseId = 1;
CollegeCourse instance = new CollegeCourse();
int expResult = 3;
int result = instance.FindCourseCountFeeByID(courseId);
assertEquals(expResult, result);
}
}
/*
* @(#)LabTest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_1;
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 24, 2008
* @author eleven
*/
public class LabTest {
public LabTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of Lab method, of class Lab.
*/
@Test
public void Lab() {
System.out.println("Lab");
int courseCount = 3;
Lab instance = new Lab();
double expResult = 15.0;
double result = instance.Lab(courseCount);
assertEquals(expResult, result);
}
}
/*
* @(#)UseCourseTest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab6.Lab6_1;
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 24, 2008
* @author eleven
*/
public class UseCourseTest {
public UseCourseTest() {
}
@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 UseCourse.
*/
@Test
public void main() {
System.out.println("main");
String[] args = null;
UseCourse.main(args);
}
}