当前位置: 首页 > news >正文

做网站的收获网页设计入门教材pdf

做网站的收获,网页设计入门教材pdf,wordpress使用视频教程,怎么去掉网站首页尾缀一、实验内容 初步掌握单元测试和TDD理解并掌握面向对象三要素#xff1a;封装、继承、多态初步掌握UML建模熟悉S.O.L.I.D原则了解设计模式 二、实验步骤 #xff08;一#xff09;单元测试 1.三种代码#xff1a;伪代码、测试代码、产品代码需求#xff1a;在一个MyUtil类…一、实验内容 初步掌握单元测试和TDD理解并掌握面向对象三要素封装、继承、多态初步掌握UML建模熟悉S.O.L.I.D原则了解设计模式 二、实验步骤 一单元测试 1.三种代码伪代码、测试代码、产品代码需求在一个MyUtil类中解决一个百分制成绩转成“优、良、中、及格、不及格”五级制成绩的功能。 伪代码百分制转五分制 如果成绩小于60转成“不及格” 如果成绩在60与70之间转成“及格” 如果成绩在70与80之间转成“中等” 如果成绩在80与90之间转成“良好” 如果成绩在90与100之间转成“优秀” 其他转成“错误” 之后用java语言编程MyUtil.java public class MyUtil{public static String percentage2fivegrade(int grade){//如果成绩小于60转成“不及格”if (grade0)return 错误;else if (grade 60)return 不及格;//如果成绩在60与70之间转成“及格”else if (grade 70)return 及格;//如果成绩在70与80之间转成“中等”else if (grade 80)return 中等;//如果成绩在80与90之间转成“良好”else if (grade 90)return 良好;//如果成绩在90与100之间转成“优秀”else if (grade 100)return 优秀;//其他转成“错误”elsereturn 错误;} } 再写一个测试代码MyUtilTest.java来检验产品代码 测试三种情况 1.正常情况 2.错误情况负数超过100的数 3.边界情况060708090100 测试代码 import junit.framework.TestCase; import org.junit.Test;public class MyUtilTest extends TestCase {Testpublic void testNormal() {assertEquals(不及格, MyUtil.percentage2fivegrade(55));assertEquals(及格, MyUtil.percentage2fivegrade(65));assertEquals(中等, MyUtil.percentage2fivegrade(75));assertEquals(良好, MyUtil.percentage2fivegrade(85));assertEquals(优秀, MyUtil.percentage2fivegrade(95));}Testpublic void testExceptions(){assertEquals(错误, MyUtil.percentage2fivegrade(105));assertEquals(错误, MyUtil.percentage2fivegrade(-55));}Testpublic void testBoundary(){assertEquals(不及格, MyUtil.percentage2fivegrade(0));assertEquals(及格, MyUtil.percentage2fivegrade(60));assertEquals(中等, MyUtil.percentage2fivegrade(70));assertEquals(良好, MyUtil.percentage2fivegrade(80));assertEquals(优秀, MyUtil.percentage2fivegrade(90));assertEquals(优秀, MyUtil.percentage2fivegrade(100));} } 测试通过截图 2.测试驱动开发TDD(测试代码-产品代码) 测试StringBufferDemo类的方法有charAt()、capacity()、indexOf()、length():char charAt(int index)返回此序列中指定索引处的 char 值。int capacity()返回当前容量。int indexOf(String str)返回第一次出现的指定子字符串在该字符串中的索引。int length()返回长度字符数。 代码 public class StringBufferDemo {public static void main(String [] args){StringBuffer buffer new StringBuffer(20);buffer.append(S);buffer.append(tringBuffer);System.out.println(buffer.charAt(1));System.out.println(buffer.capacity());System.out.println(buffer.indexOf(tring12345));System.out.println(buffer buffer.toString());System.out.println(buffer.length());} } 测试代码 import junit.framework.TestCase; import org.junit.Test;public class StringBufferDemoTest extends TestCase {StringBuffer a new StringBuffer(StringBuffer);StringBuffer b new StringBuffer(StringBufferStringBuffer);StringBuffer c new StringBuffer(StringBufferStringBufferStringBuffer);Testpublic void testcharAt() throws Exception{assertEquals(S,a.charAt(0));assertEquals(n,a.charAt(4));assertEquals(u,a.charAt(7));}public void testcapacity() throws Exception{assertEquals(28,a.capacity());assertEquals(40,b.capacity());assertEquals(52,c.capacity());}public void testlength() throws Exception{assertEquals(12,a.length());assertEquals(24,b.length());assertEquals(36,c.length());}public void testindexOf() throws Exception{assertEquals(0,a.indexOf(Str));assertEquals(5,a.indexOf(gBu));assertEquals(6,b.indexOf(Buf));assertEquals(7,b.indexOf(uff));assertEquals(9,c.indexOf(fer));assertEquals(10,c.indexOf(erS));} } 测试通过截图 二对设计模式示例进行扩充让其支持Long类 要求支持Long类这样需Document类修改构造方法这违背了OCP原则。封装、继承、多态解决不了问题需要添加class Long extends Dataclass LongFactory extends Factory 代码 abstract class Data {abstract public void DisplayValue(); } class Integer extends Data {int value;Integer() {value100;}public void DisplayValue(){System.out.println (value);} } class Long extends Data {long value;Long(){value2017530999;}public void DisplayValue(){System.out.println(value);} } abstract class Factory {abstract public Data CreateDataObject(); } class IntFactory extends Factory {public Data CreateDataObject(){return new Integer();} } class LonFactory extends Factory {public Data CreateDataObject(){return new Long();} } class Document {Data pd;Document(Factory pf){pd pf.CreateDataObject();}public void DisplayData(){pd.DisplayValue();} } public class MyDoc {static Document e;public static void main(String[] args) {enew Document(new LonFactory());e.DisplayData();} } 运行通过截图 三以TDD的方式开发一个复数类Complex 方法 getA(int a);返回实部 getB(int b);返回虚部 ComplexAdd(Complex c);实现复数相加 ComplexMinus(Complex c);实现复数相减 ComplexMulti(Complex c);实现复数相乘 ComplexDiv(Complex c);实现复数相除 代码 public class Complex { //a biprivate double a;private double b;public Complex(){ //构造方法置0this.a 0;this.b 0;}public Complex(double a, double b) { //构造方法初始化一个复数this.a a;this.b b;}public double getA(){ //获取实部return this.a;}public double getB(){ //获取虚部return this.b;}public double setA(double a){ //设置实部this.a a;return a;}public double setB(double b){ //设置虚部this.b b;return b;}Complex ComplexAdd(Complex c){//复数相加double a c.getA();double b c.getB();double newA a this.a;double newB b this.b;Complex Result new Complex(newA,newB);return Result;}Complex ComplexMinus(Complex c){//复数相减double a c.getA();double b c.getB();double newA a - this.a;double newB b - this.b;Complex Result new Complex(newA,newB);return Result;}Complex ComplexMulti(Complex c){//复数相乘double a c.getA();double b c.getB();double newA a * this.a;double newB b * this.b;Complex Result new Complex(newA,newB);return Result;}Complex ComplexDiv(Complex c){//复数相乘double a c.getA();double b c.getB();double newA a / this.a;double newB b / this.b;Complex Result new Complex(newA,newB);return Result;}public String toString() {String s ;if (b 0)s a b i;if (b 0)s a ;if (b 0)s a b i;return s;} } 测试代码 import junit.framework.TestCase; import org.junit.Test; import static org.junit.Assert.*;public class ComplexTest extends TestCase {Complex c1 new Complex(0, 3);Complex c2 new Complex(-1, -1);Complex c3 new Complex(2,1);Testpublic void testgetRealPart() throws Exception {assertEquals(-1.0, new Complex().setA(-1.0));assertEquals(5.0, new Complex().setA(5.0));assertEquals(0.0, new Complex().setA(0.0));}Testpublic void testgetImagePart() throws Exception {assertEquals(-1.0, new Complex().setB(-1.0));assertEquals(5.0, new Complex().setB(5.0));assertEquals(0.0, new Complex().setB(0.0));}Testpublic void testComplexAdd() throws Exception {assertEquals(-1.02.0i, c1.ComplexAdd(c2).toString());assertEquals(2.04.0i, c1.ComplexAdd(c3).toString());assertEquals(1.0, c2.ComplexAdd(c3).toString());}Testpublic void testComplexSub() throws Exception {assertEquals(-1.0 -4.0i, c1.ComplexMinus(c2).toString());assertEquals(2.0 -2.0i, c1.ComplexMinus(c3).toString());assertEquals(3.02.0i, c2.ComplexMinus(c3).toString());}Testpublic void testComplexMulti() throws Exception {assertEquals(-0.0 -3.0i, c1.ComplexMulti(c2).toString());assertEquals(0.03.0i, c1.ComplexMulti(c3).toString());assertEquals(-2.0 -1.0i, c2.ComplexMulti(c3).toString());}Testpublic void testComplexComplexDiv() throws Exception {assertEquals(-0.0 -3.0i, c2.ComplexDiv(c1).toString());assertEquals(-0.0 -3.0i, c2.ComplexDiv(c1).toString());assertEquals(-2.0 -1.0i, c2.ComplexDiv(c3).toString());} } 测试截图 四面向对象三要素 使用UML对实验二中代码进行建模 代码 public abstract class Animal {private String color;public String getColor() {return color;}public void setColor(String color) {this.color color;}public abstract String shout(); } public class Dog extends Animal{public String shout(){return 汪汪;}public String toString(){return The Dogs color is this.getColor() , and it shouts this.shout() !;} } public class Cat extends Animal{public String shout(){return 喵喵;}public String toString(){return The Cats color is this.getColor() , and it shouts this.shout() !;} } UML图 实验中遇到的问题 1.Junit的包安装上之后无法使用。 解决办法最开始只装了一个junit.jar的包没有装另外一个junit-4.12.jar的包导致无法使用 2.UML软件不会使用 解决办法参考教程https://blog.csdn.net/luansha0/article/details/82260678 PSP 步骤耗时百分比需求分析30min10%设计30min10%代码实现110min36.7%测试70min23.3%分析总结60min20%感悟 不知道怎么回事老师的博客图片不能显示对我做实验造成了极大的困扰后来参照着20175306王佳烁、20175313张黎仙同学的博客上面的步骤才得以完成再此谢谢二位前辈 参考博客 20175306王佳烁https://www.cnblogs.com/wjs123456/p/10700936.html 20175313张黎仙https://www.cnblogs.com/xiannvyeye/p/10720425.html 转载于:https://www.cnblogs.com/20175309lyh/p/10733744.html
http://wiki.neutronadmin.com/news/350644/

相关文章:

  • 随州市住房和城乡建设部网站装饰网站建设多少钱
  • 上海正规网站制作价格运行中怎么打开wordpress
  • wap 网站源码wordpress 文章列表分页
  • 漯河高端网站建设后端开发工资一般多少
  • 深圳移动网站建设公司wordpress 上传大图
  • 烟台百度网站建设推广自己电脑做网站iis
  • 南通网站建设制作公司创业论坛网站有哪些
  • 合肥网站建设代理商wordpress本地连接
  • wordpress网站地图自动更新郑州网站外包哪家好
  • 一个空间能放几个网站开源社区的发展前景
  • 怎么知道一个网站是哪家公司做的百度外卖网站建设与维护方法
  • 可以做围棋题的网站在百度做网站赚钱吗
  • wordpress 禁用更新西安网站优化招聘网
  • 网站备案登录密码找回网站展示 包括什么
  • 淘宝开放平台怎么做淘宝客网站wordpress模板脚步代码哪里修改
  • 什么样的网站利于seowordpress 获取文章数量
  • 长春电商网站建设公司排名广州网页制作网站维护
  • 天津手网站开发全网推广方案
  • 大连 响应式网站平面广告创意作品
  • 建设有限公司网站济南做网站公司电话
  • 我40岁自学cad找到工作了南昌seo搜索排名
  • 优秀的电商网站app定制公司哪个好用
  • 盘锦工程建设信息网站赣州新闻头条
  • 想找人帮我做网站长沙专业网站建设哪家好
  • 网站好玩代码和特效企业网站程序
  • 游戏服务器搭建 开服西安做网站优化的公司
  • 重庆网站建立深圳平面设计公司排名榜
  • 从化网站建设优化那个网站做旅游规划好
  • 网站的功能建设wordpress验证ticket
  • 做视频大赛推广的网站如何维护自己公司网站