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

Berkeley CS 61B Data Structures(in Java) Lab2 讨论帖

 
🔗
Glaces 2018-4-20 19:18:19 | 只看该作者
全局:
本帖最后由 Glaces 于 2018-4-20 19:24 编辑

Testing constructors and toString():
The fraction f0 is 0/1
The fraction f1 is 3/1
The fraction f2 is 3/5
The fraction f3 is 3/5, which should equal f2

Testing add:
The sum of 3/1 and 3/5 is 18/5
The sum of 0/1, 3/1 and 3/5 is 18/5

Testing changeNumerator and fracs:
Now f3 is 7/20, which should be 7/20
The total number of Fraction objects is 6

Testing gcd:
The gcd of 2 and 10 is: 2
The gcd of 15 and 5 is: 5
The gcd of 24 and 18 is: 6
The gcd of 10 and 10 is: 10
The gcd of 21 and 400 is: 1
回复

使用道具 举报

🔗
daisyly007 2018-5-29 18:28:27 | 只看该作者
全局:

Testing constructors and toString():
The fraction f0 is 0/1
The fraction f1 is 3/1
The fraction f2 is 3/5
The fraction f3 is 3/5, which should equal f2

Testing add:
The sum of 3/1 and 3/5 is 18/5
The sum of 0/1, 3/1 and 3/5 is 18/5

Testing changeNumerator and fracs:
Now f3 is 7/20, which should be 7/20
The total number of Fraction objects is 7

Testing gcd:
The gcd of 2 and 10 is: 2
The gcd of 15 and 5 is: 5
The gcd of 24 and 18 is: 6
The gcd of 10 and 10 is: 10
The gcd of 21 and 400 is: 1
回复

使用道具 举报

全局:
换了一个浏览器依旧不能上传图片... 那就也说一下心得吧。
lab2作业真的好,和lecture环环相扣,难易程度依次递增。听lecture的时候感觉听懂了,一到练习就懵逼。一上来连类里怎么调用方法都没想到。自己太辣鸡了。后来把lecture3翻出来重新听一遍才发觉之前有太多小点被遗漏了,shewchuk教授是我新晋男神讲的真清楚,是我自己没理解好。
还有大家看的好仔细呀...我都没发现System.out.println("The total number of Fraction objects is " +f3. fracs());那里还有一个f3. 这么一看fracs()函数确实和f3没关系,它调用的时候也不会分配this.
关于在构造函数中用this()调用其他构造函数,除了上面大家的总结,还有以下几点: 使用this()必须在起始行;一个constructor内只能调用一个另一个constructor;不能在constructor之外的任何函数调用constructor。



回复

使用道具 举报

全局:
VarlarMorghulis 发表于 2018-7-22 22:49
换了一个浏览器依旧不能上传图片... 那就也说一下心得吧。
lab2作业真的好,和lecture环环相扣,难易程度 ...

啊不能发图的话我也粘贴一下console的结果好了TT
Testing constructors and toString():
The fraction f0 is 0/1
The fraction f1 is 3/1
The fraction f2 is 3/5
The fraction f3 is 3/5, which should equal f2

Testing add:
The sum of 3/1 and 3/5 is 18/5
The sum of 0/1, 3/1 and 3/5 is 18/5

Testing changeNumerator and fracs:
Now f3 is 7/20, which should be 7/20
The total number of Fraction objects is 7

Testing gcd:
The gcd of 2 and 10 is: 2
The gcd of 15 and 5 is: 5
The gcd of 24 and 18 is: 6
The gcd of 10 and 10 is: 10
The gcd of 21 and 400 is: 1
回复

使用道具 举报

🔗
martinma 2018-7-24 21:56:48 | 只看该作者
全局:

回复

使用道具 举报

🔗
yang0190 2018-7-27 04:46:31 | 只看该作者
全局:
一开始很疑惑为什么f3没有调用toString或gcd也会进行约分,后来觉得是在system.out.println里系统自动调用了已修改过的toString,不知道对不对。



result.png (44.65 KB, 下载次数: 0)

result.png
回复

使用道具 举报

🔗
cecilia.yyw 2018-8-1 02:25:40 | 只看该作者
本楼:
全局:
Finally~~~

Lab2.JPG (36.87 KB, 下载次数: 0)

Lab2.JPG
回复

使用道具 举报

🔗
mc_king 2018-9-16 05:34:44 | 只看该作者
全局:
上传截图打卡

Screen Shot 2018-09-15 at 2.32.30 PM.png (140.88 KB, 下载次数: 0)

Screen Shot 2018-09-15 at 2.32.30 PM.png
回复

使用道具 举报

🔗
shimei 2019-3-1 10:09:22 | 只看该作者
全局:
作业打卡

回复

使用道具 举报

🔗
wimp 2019-3-8 16:12:41 | 只看该作者
全局:
调用已有对象的constructor忘记改了,返工了一下

QQ截图20190308161027.png (45.35 KB, 下载次数: 0)

QQ截图20190308161027.png
回复

使用道具 举报

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

本版积分规则

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