随笔分类 -  JUnit

摘要:使用继承的方式来实现适配器模式 //目标类,它的方法里面调用Adaptee对象的方法public interface Target{ public void method1();}//被适配对象,它的方法会被Target类的方法调用。public class Adaptee{ public void method2() { System.out.println("method2 invoked"); }}//使用继承的方式来实现适配器模式 //适配器对象,实现用Target类的方法调用Adaptee类的方法,起到一个中间转化的作用。public class Adapter 阅读全文
posted @ 2011-08-17 22:57 水之原 阅读(646) 评论(0) 推荐(0) 编辑
摘要:对计算器进行单元测试package com.anllin.junit;public class Calculator{ public int add(int a, int b) { return a + b; } public int subtract(int a, int b) { return a - b; } public int multiply(int a, int b) { return a * b; } public int devide(int a, int b) throws Exception { if(0 == b) { throw new Exception(" 阅读全文
posted @ 2011-08-17 22:55 水之原 阅读(811) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示