楼主: jaly50
跳转到指定楼层
上一主题 下一主题
收起左侧

Berkeley CS 61B Data Structures(in Java) Homework4 加分+讨论帖

 
🔗
mmyn 2017-5-6 14:47:48 | 只看该作者
全局:
打卡,经历了Project1四个part的洗礼之后,感觉这种homework已经无所畏惧了
回复

使用道具 举报

🔗
ienric 2017-5-10 12:43:20 | 只看该作者
全局:
感谢第一页的人给的启发,挣扎下完成作业了
更多图片 小图 大图
组图打开中,请稍候......
回复

使用道具 举报

🔗
spirit660640 2017-5-10 18:50:32 | 只看该作者
全局:
本帖最后由 spirit660640 于 2017-5-10 18:54 编辑

参考了楼里同学的想法。多谢楼主的testcode,希望自己以后也能写出这么好的testcode。最后明白了LockList只需要将newNode变成LockListNode也就是加上自身的功能就可以了。所以只需要修改newNode这样每一个新建的Node都带有lock与否的变量。
另外修改remove,添加lockNode。
还学会了怎么调用super的函数。
也更了解了package的概念以及protected,private 和public的区别。

更多图片 小图 大图
组图打开中,请稍候......
回复

使用道具 举报

🔗
SJTed 2017-5-15 22:05:31 | 只看该作者
全局:
学到了instanceof。。。发现自己小毛病特别多,容易忘记大小写。。
更多图片 小图 大图
组图打开中,请稍候......
回复

使用道具 举报

🔗
mrhfw 2017-5-17 21:28:34 | 只看该作者
全局:
一开始没搞明白第三问什么意思,非常感谢楼上几位同学的分析终于弄出来了。 看来多态继承的理解还不到位


回复

使用道具 举报

🔗
sybilibla 2017-5-19 01:32:37 | 只看该作者
全局:
感谢第一页同学们的指点和帮助,半知半解地也算是做出来了。做override的过程中,发现自己已经完全忘了super的用法,顺便重新巩固了一下
更多图片 小图 大图
组图打开中,请稍候......
回复

使用道具 举报

🔗
布瓜小白 2017-5-27 16:21:01 | 只看该作者
全局:
时隔大半个月做作业……发现版主早就不打分了,就懒得贴图了。。打卡笔记。。。
求问解释一下partII?怎么样破坏DList里的invariant?

1. DList的构造函数忘记设置head, 导致NullPointerException。
1. override2个函数。newNode()里把所有DListNode标记成LockDListNode,DList的所有函数即可继承。
回复

使用道具 举报

🔗
arieslpx 2017-6-1 22:13:44 | 只看该作者
全局:
继承这个概念挺好理解的但是实际操作起来其实还有点困难
这个作业真的特别好 让我对继承多态又有了更深的理解

hw4.png (7.25 KB, 下载次数: 0)

hw4.png
回复

使用道具 举报

🔗
AllenChen 2017-6-3 21:53:35 | 只看该作者
全局:
除了好多问题,看了别人的代码菜终于找到bug,自己对继承了解不够,打算找本书继续看一下。
更多图片 小图 大图
组图打开中,请稍候......
回复

使用道具 举报

🔗
liniua 2017-6-4 07:17:34 | 只看该作者
全局:
Now we are testing DList.
Here is a list after insertBack 6, 9, 12: [  6  9  12  ]

Here is the same list after insertBack(15) and insertFront(3): [  3  6  9  12  15  ]

front() should be 3. It is: 3
front's next should be 6. It is: 6
front's next's prev should be 3. It is: 3
After remove the front, the front() should be 6. It is: 6
After insertBefore() and insertAfter(), The first 3 nodes should be 5,6,8. The list is: [  5  6  8  9  12  15  ]

Here is a list after construction: [  ]
isEmpty() should be true. It is: true
length() should be 0. It is: 0
Here is a list after insertFront(3) to an empty list: [  3  ]
Here is a list after insertBack(5) on an empty list: [  5  ]

Here is a list after insertFront 3, 2, 1: [  1  2  3  ]
isEmpty() should be false. It is: false
length() should be 3. It is: 3
Here is the same list after insertBack(4): [  1  2  3  4  ]

Here is a list after insertBack 6, 7: [  6  7  ]
isEmpty() should be false. It is: false
length() should be 2. It is: 2
Here is the same list after insertFront(5): [  5  6  7  ]

Process finished with exit code 0
==========================================

Now we are testing LockDList.
Here is a list after insertBack 6, 9, 12: [  6  9  12  ]

Here is the same list after insertBack(15) and insertFront(3): [  3  6  9  12  15  ]

front() should be 3. It is: 3
front's next should be 6. It is: 6
front's next's prev should be 3. It is: 3
We lockNode front()= 3
After remove the locked front, the front() should still be 3. It is: 3
After remove the back, the back() should be 12. It is: 12
After insertBefore(3) and insertAfter(3), The first 3 nodes should be 5,3,8. The list is: [  5  3  8  6  9  12  ]

Here is a list after construction: [  ]
isEmpty() should be true. It is: true
length() should be 0. It is: 0
Here is a list after insertFront(3) to an empty list: [  3  ]
Here is a list after insertBack(5) on an empty list: [  5  ]

Here is a list after insertFront 3, 2, 1: [  1  2  3  ]
isEmpty() should be false. It is: false
length() should be 3. It is: 3
Here is the same list after insertBack(4): [  1  2  3  4  ]

Here is a list after insertBack 6, 7: [  6  7  ]
isEmpty() should be false. It is: false
length() should be 2. It is: 2
Here is the same list after insertFront(5): [  5  6  7  ]

Process finished with exit code 0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表