Ex0?

0 views
Skip to first unread message

Lucas Amorim

unread,
Jun 9, 2011, 10:12:53 AM6/9/11
to BYU CS 142 (Spring 2011) [McCarthy]
Do we need to actually write a program for Ex0 or can we do the
tracking just on our defense?

Jay McCarthy

unread,
Jun 12, 2011, 1:09:33 AM6/12/11
to byu-cs-jm-14...@googlegroups.com
Just do the tracking. A comment is fine.

2011/6/9 Lucas Amorim <amor...@gmail.com>:


> Do we need to actually write a program for Ex0 or can we do the
> tracking just on our defense?

--
Jay McCarthy <j...@cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93

Lucas Amorim

unread,
Jun 13, 2011, 12:23:28 AM6/13/11
to BYU CS 142 (Spring 2011) [McCarthy]
return String.format("letters: %d%nwords: %d%nlines: %d%n",
letterCount(f,0), wordCount(f, 0), lineCount(f,0));

For some reason, my letterCount works here but the other two return 0
where when I just call on them alone, they work fine.

Why is this?

Darth Scythe

unread,
Jun 13, 2011, 1:19:21 AM6/13/11
to byu-cs-jm-14...@googlegroups.com
I had the same problem as Lucas here, did anyone figure this out?
Joseph Hilton

Blake Johnson

unread,
Jun 13, 2011, 2:15:35 AM6/13/11
to byu-cs-jm-14...@googlegroups.com
This problem is because f.read() mutates f, so you actually need to create a new FileReader for each one. The way you have it written, the file has already been read when you call wordCount and lineCount, so f.read() will just return -1. Also, that approach to Ex0 is wrong, you are only supposed to read the file once and figure out all of the counts at the same time instead of reading the file 3 times.

Blake

Lucas Amorim

unread,
Jun 13, 2011, 10:39:44 AM6/13/11
to byu-cs-jm-14...@googlegroups.com
How can I go about doing this?

By doing all of my calculations in one conditional simultaneously? Is this possible? 

Any hints?

Jay McCarthy

unread,
Jun 13, 2011, 11:26:07 AM6/13/11
to byu-cs-jm-14...@googlegroups.com, byu-cs-jm-14...@googlegroups.com
Make a data definition for the values read will return and do the design process

iPhoneから送信
Reply all
Reply to author
Forward
0 new messages