哈工大软件构造LAB2

一:有步骤地进行编写ADT

为什么先要写specific ,test,然后再写方法呢?

我地一点小小的理解是:只要test写对了,那么在实现方法后可以马上调用对用地test方法进行检查,遇到报错咱们就要去修正、完善自己的方法。

高效的流程:

All your classes must have clear documented specifications.

Deciding on its spec, devise, document, and implement tests for a class.

And then to implement  the class ,once you implement one function in the class, you can use the corresponding testfunction to test it.

二:关于构造器与变量的关系

如果类中的变量只是声明,没有赋值,那么generate constructor就会生成对应的赋值方法。

如果类中的变量全都赋值了,不需要生成constructor,默认的空参构造器就好了。

三:问题记录(存在我没懂得东西,P1/graph/ConcreteEdgesGraph.java)

 for(Edge<String> edge:edges)
                {
                    if (edge.edgeEqual(newEdge)){
                        back = edge.getWeight();
                        edges.remove(edge);
                        break;
//                        return back;
                        //为什么这一行删了就不行呢,很奇怪
                    }
                }

四:语法的替代:

 edges.removeIf(edge -> Objects.equals(edge.getSource(), vertex) | Objects.equals(edge.getTarget(), vertex));

五:这是什么原因:

 六:

 一:Wrapping the FileReader in a BufferedReader

You should really taste the processing where wrapping the FileReader in a BufferedReader.

File corpus = "src/poet/mugar-omni-theater.txt";
FileReader fileReader = new FileReader(corpus);
BufferedReader bufferedReader = new BufferedReader(fileReader);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值