1. Senior Member
Join Date
May 2010
Posts
112
Rep Power
0
I am figuring out how the code works.

2. Senior Member
Join Date
May 2010
Posts
112
Rep Power
0
I believe i will understand it.

3. Senior Member
Join Date
May 2010
Posts
112
Rep Power
0
LJ apart from Lectures videos and the book art and science of Java(eric roberts).What materials do you use.Any suggestion for me to improve my java skills.do you practise alot?

Thank you.

4. Originally Posted by Learning Java
My book doesn't mention anything about adding days of the week :confused: Have you a different version of the book? Or was this something you thought would make the program better? Does sound like a good idea though actually! :)
there is a different version of the book. i think you can find it in a torrent, but i am just using the preliminary Draft version

i think this exercise was also used in a previous stanford intake as a section exercise.
CS106A Handouts
these exercises and handouts are very similar to the ones given in the with the online course zip.
i think thats where i got my initial version from but it is essentially the same as the book but with days added on the top row.
An additional requirement was to have the correct number of rows for the days. So that if February started on a Sunday, you would only have 4 rows
where as if March started on a Saturday you would need 6 rows.

this is my simplified version without the days of the week added.
the OP would do well to compare both methods and note that there is seldom one singular solution

Java Code:
public class calendar extends GraphicsProgram {
private static final int DAYS_IN_WEEK = 7;
private static final int DAYS_IN_MONTH = 31;
private static final int DAY_WIDTH = 80;
private static final int DAY_HEIGHT = 60;
/* (Sunday = 0, Monday = 1, Tuesday = 2, and so on)*/
private static final int DAY_MONTH_STARTS = 5;

public void run() {
int rows = (DAYS_IN_MONTH + DAY_MONTH_STARTS) / DAYS_IN_WEEK;
if ((DAY_MONTH_STARTS + DAYS_IN_MONTH) % DAYS_IN_WEEK != 0){
rows++;
}

for (int i = 0; i < rows; i++) {
int y = i * DAY_HEIGHT;

for (int j = 0; j < DAYS_IN_WEEK; j++) {
int x = j * DAY_WIDTH;

int date = (((DAYS_IN_WEEK * i) + j) - DAY_MONTH_STARTS) + 1;

if (date > 0 && date <= DAYS_IN_MONTH) {
add(new GLabel("" + date + ".", x + 25, y + 35));
}

}
}
}

}

Originally Posted by ccie007
LJ apart from Lectures videos and the book art and science of Java(eric roberts).What materials do you use.Any suggestion for me to improve my java skills.do you practise alot?

Thank you.
here is a good tutorial that you should consider doing when you get a convienient place in the course.
if you just finished a chapter why not look at it now.
Eclipse and Java for Total Beginners

it more about how to use eclipse than it is about java.
you can download the videos and watch and type along with the example.
you will learn a lot about the functionality of eclipse and it will save you a good deal of typing. its 16 15-minute videos.

You will find that as you progress through 106a you will have to go and find out all sorts of stuff yourself

the sun java tutorials are a good source of reference learning material
The Java™ Tutorials

also the API will prove invaluable as a reference to the many Java classes when you get a little further.
Overview (Java 2 Platform SE v1.4.2)

similar documantation for the acm libraries which are used in 106a can be found here

Generated Documentation (Untitled)
Last edited by sonny; 05-24-2010 at 04:32 PM.

5. Senior Member
Join Date
May 2010
Posts
112
Rep Power
0
Thank you Sonny I will go through them.Much obliged mate.

6. Senior Member
Join Date
May 2010
Location
London
Posts
106
Rep Power
0
Originally Posted by ccie007
LJ apart from Lectures videos and the book art and science of Java(eric roberts).What materials do you use.Any suggestion for me to improve my java skills.do you practise alot?

Thank you.
Nothing else really, I've started going through the Mark Dexter videos though. I have had a lot of help from people on this forum.

I don't practice enough to be honest.

7. Senior Member
Join Date
May 2010
Posts
112
Rep Power
0
Cool.I am going through those videos (Mark) too;)

8. Senior Member
Join Date
May 2010
Location
London
Posts
106
Rep Power
0
I wonder whether now is a good time for you to be going through those Mark Dexter videos.

Are you understanding them?

9. Senior Member
Join Date
May 2010
Posts
112
Rep Power
0
Well...is it quite early to go through those at the moment.

10. Senior Member
Join Date
May 2010
Posts
112
Rep Power
0
i believe i will understand them if i try.

11. ## Re: Java Checkerboad question CS106A Stanford univerity

What parameters does the GRect constructor take?

12. ## Re: Java Checkerboad question CS106A Stanford univerity

Sorry Junky. I moved the post to its own thread.

Page 4 of 4 First ... 234

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•