p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_java thread: RE: Chap4 question 4 beginning java 2 jdsk 1.3


Message #1 by Jonathan Gold <jonnygee@p...> on Thu, 11 Apr 2002 20:00:01 -0700
Julian, I think it was you who mentioned "patterns." There is a free book,
on the web, by Bruce Eckel, called "Thinking in Patterns". I haven't looked
at it yet, tho I have downloaded it. The same Bruce Eckel also has a free
book called "Thinking in Java". I got this far: that when he was writing
"Thinking in Java" he began to see that there was a fundamental issue about
recognizing patterns, and he got into that as another book. Here's the URL
to d'load either or both of them:

http://64.78.49.204/

HTH,

Jonathan

Jonathan Gold
jonnygee@p...


>
> Yea I actually went a couple pages into Chap 5 also, really interesting,
> it's like "yes finally we're getting right into the language", however I
> have opted to hold myself back in favor of REALLY understanding these
> chapter 4 problems, I know where i'm getting stuck, it's at the
> design and
> implementation of the program, not so much the syntax or the commands.
> There are alot of "tricks" and patterns i'm trying to train myself to see
> and pickup...and it's working..it's coming slowly, however i'm not gonna
> continue until i'm sure i can do those problems myself without help.
>
> Anyway lemme know if anything gets explained better along in chap 5 so
> maybe it will clear me up if i proceed also...
>
> -Julian
> ---
> Do you need true END-TO-END (e2e) Java Messaging (JMS)?  Softwired
> offers industry's ONLY complete 100% JMS messaging solutions for your
> needs TODAY.
> Visit
> http://adtracking.wrox.com/track.asp?x=p2p%2Fe%2Fjava%2Dsoftwired&
url=www.softwired-inc.com Our unique product range includes: iBus//Mobile
(wireless data),
iBus//MessageBus (IP Multicast), iBus//MessageServer (store and forward)
and much more!


Message #2 by Jonathan Gold <jonnygee@p...> on Thu, 11 Apr 2002 18:55:44 -0700
Not just you :) I'm amazed at how "delicate" the language is: even the
tiniest mis-step and I get compiler errors.
I guess the other side of that is that I'll be forced to really think out
what I'm doing every step of the way. I'm into chapter 5 right now - just a
few pages - and it's very exciting: kind of the knitty gritty about what
"classes" are and how they're constructed. When all is said and done,
there's a lot of detail to have to remember, so I'm hoping I have enough
brain cells to do it with.
Yeah, as you said, keep truckin'.

Jonathan

Jonathan Gold
jonnygee@p...

> -----Original Message-----
> From: digi [mailto:digitalsy@h...]
> Sent: Thursday, April 11, 2002 7:44 PM
> To: Beginning Java
> Subject: [beginning_java] RE: Chap4 question 4 beginning java 2 jdsk 1.3
>
>
> > Julian, I think this is because we are referencing into an ARRAY, and an
> array is counted from '0', whereas our months are counted 1 to 12. So
> array-month 0 is January, array-month 1 is February, and so on.
>
> Jonathan Gold
> jonnygee@p...
>
> > -----Original Message-----
> > From: digi [mailto:digitalsy@h...]
> > Sent: Thursday, April 11, 2002 6:16 PM
> > To: Beginning Java
> > Subject: [beginning_java] Chap4 question 4 beginning java 2 jdsk 1.3
> >
> >
> > Ok well here i am struggling away with these exercises....I get what has
> > to be done, and I write it down and go step by step however i
> > just come to
> > a blockade when it comes to writing the code...
> >
> > So i looked at the answers the code that i downloaded here and there's a
> > part that doesn't make sense (to me)
> >
> > // Generate a set of arbitrary dates in this century - 1/1/1900 to
> > 31/12/1999
> >     for(int i = 0; i < dates.length; i++)
> >     {
> >       year = (int)(100.0*Math.random());                //
> > Generate year 0
> > to 99 inclusive
> >       month = (int)(12.0*Math.random()) + 1;            //
> Generate month
> > 1 to 12 inclusive
> >
> >       // Generate random date in the month
> >       if((year>0) && (year % 4 == 0) && (month == 2))   // if it's
> > February in a leap year
> > 	day = (int)((daysInMonth[month-1] + 1.0)*Math.random()) + 1;  //
> > Date can be 1 to 29
> >       else	                                                      //
> > Otherwise
> > 	day = (int)(daysInMonth[month-1]*Math.random()) + 1;          //
> > as normal
> >
> > --------------
> > why is it that if it's a leap year, february in the if we do daysInMonth
> > [month-1] why minus 1? that won't give us the proper days in february
> > and for the else, the same deal...however if i removed the -1 from both
> > square brackets i would get an error when i try to run it.
> >
> > Please explain someone
> >
> > -Julian
> > ---
> > Do you need true END-TO-END (e2e) Java Messaging (JMS)?  Softwired
> > offers industry's ONLY complete 100% JMS messaging solutions for your
> > needs TODAY.
> > Visit
> > http://adtracking.wrox.com/track.asp?x=p2p%2Fe%2Fjava%2Dsoftwired&
> url=www.softwired-inc.com Our unique product range includes: iBus//Mobile
> (wireless data),
> iBus//MessageBus (IP Multicast), iBus//MessageServer (store and forward)
> and much more!
>
>
> Doh! You're right...damn it's little things like that we gotta watch out
> for. Wow...and i even knew that, i just overlooked it. Maybe i'm not
> getting enuff sleep these days...heh...well i'll keep truckin...these
> examples are really intense.
>
> Thanks by the way :)
> -Julian
> ---
> Do you need true END-TO-END (e2e) Java Messaging (JMS)?  Softwired
> offers industry's ONLY complete 100% JMS messaging solutions for your
> needs TODAY.
> Visit
> http://adtracking.wrox.com/track.asp?x=p2p%2Fe%2Fjava%2Dsoftwired&
url=www.softwired-inc.com Our unique product range includes: iBus//Mobile
(wireless data),
iBus//MessageBus (IP Multicast), iBus//MessageServer (store and forward)
and much more!


Message #3 by "digi" <digitalsy@h...> on Fri, 12 Apr 2002 03:20:33
> Not just you :) I'm amazed at how "delicate" the language is: even the
tiniest mis-step and I get compiler errors.
I guess the other side of that is that I'll be forced to really think out
what I'm doing every step of the way. I'm into chapter 5 right now - just a
few pages - and it's very exciting: kind of the knitty gritty about what
"classes" are and how they're constructed. When all is said and done,
there's a lot of detail to have to remember, so I'm hoping I have enough
brain cells to do it with.
Yeah, as you said, keep truckin'.

Jonathan

Jonathan Gold
jonnygee@p...

> -----Original Message-----
> From: digi [mailto:digitalsy@h...]
> Sent: Thursday, April 11, 2002 7:44 PM
> To: Beginning Java
> Subject: [beginning_java] RE: Chap4 question 4 beginning java 2 jdsk 1.3
>
>
> > Julian, I think this is because we are referencing into an ARRAY, and 
an
> array is counted from '0', whereas our months are counted 1 to 12. So
> array-month 0 is January, array-month 1 is February, and so on.
>
> Jonathan Gold
> jonnygee@p...
>
> > -----Original Message-----
> > From: digi [mailto:digitalsy@h...]
> > Sent: Thursday, April 11, 2002 6:16 PM
> > To: Beginning Java
> > Subject: [beginning_java] Chap4 question 4 beginning java 2 jdsk 1.3
> >
> >
> > Ok well here i am struggling away with these exercises....I get what 
has
> > to be done, and I write it down and go step by step however i
> > just come to
> > a blockade when it comes to writing the code...
> >
> > So i looked at the answers the code that i downloaded here and there's 
a
> > part that doesn't make sense (to me)
> >
> > // Generate a set of arbitrary dates in this century - 1/1/1900 to
> > 31/12/1999
> >     for(int i = 0; i < dates.length; i++)
> >     {
> >       year = (int)(100.0*Math.random());                //
> > Generate year 0
> > to 99 inclusive
> >       month = (int)(12.0*Math.random()) + 1;            //
> Generate month
> > 1 to 12 inclusive
> >
> >       // Generate random date in the month
> >       if((year>0) && (year % 4 == 0) && (month == 2))   // if it's
> > February in a leap year
> > 	day = (int)((daysInMonth[month-1] + 1.0)*Math.random()) + 1;  //
> > Date can be 1 to 29
> >       else	                                                      //
> > Otherwise
> > 	day = (int)(daysInMonth[month-1]*Math.random()) + 1;          //
> > as normal
> >
> > --------------
> > why is it that if it's a leap year, february in the if we do 
daysInMonth
> > [month-1] why minus 1? that won't give us the proper days in february
> > and for the else, the same deal...however if i removed the -1 from both
> > square brackets i would get an error when i try to run it.
> >
> > Please explain someone
> >
> > -Julian
> > ---
> > Do you need true END-TO-END (e2e) Java Messaging (JMS)?  Softwired
> > offers industry's ONLY complete 100% JMS messaging solutions for your
> > needs TODAY.
> > Visit
> > http://adtracking.wrox.com/track.asp?x=p2p%2Fe%2Fjava%2Dsoftwired&
> url=www.softwired-inc.com Our unique product range includes: iBus//Mobile
> (wireless data),
> iBus//MessageBus (IP Multicast), iBus//MessageServer (store and forward)
> and much more!
>
>
> Doh! You're right...damn it's little things like that we gotta watch out
> for. Wow...and i even knew that, i just overlooked it. Maybe i'm not
> getting enuff sleep these days...heh...well i'll keep truckin...these
> examples are really intense.
>
> Thanks by the way :)
> -Julian
> ---
> Do you need true END-TO-END (e2e) Java Messaging (JMS)?  Softwired
> offers industry's ONLY complete 100% JMS messaging solutions for your
> needs TODAY.
> Visit
> http://adtracking.wrox.com/track.asp?x=p2p%2Fe%2Fjava%2Dsoftwired&
url=www.softwired-inc.com Our unique product range includes: iBus//Mobile
(wireless data),
iBus//MessageBus (IP Multicast), iBus//MessageServer (store and forward)
and much more!


Yea I actually went a couple pages into Chap 5 also, really interesting, 
it's like "yes finally we're getting right into the language", however I 
have opted to hold myself back in favor of REALLY understanding these 
chapter 4 problems, I know where i'm getting stuck, it's at the design and 
implementation of the program, not so much the syntax or the commands. 
There are alot of "tricks" and patterns i'm trying to train myself to see 
and pickup...and it's working..it's coming slowly, however i'm not gonna 
continue until i'm sure i can do those problems myself without help.

Anyway lemme know if anything gets explained better along in chap 5 so 
maybe it will clear me up if i proceed also...

-Julian
Message #4 by Jonathan Gold <jonnygee@p...> on Thu, 11 Apr 2002 18:21:52 -0700
Julian, I think this is because we are referencing into an ARRAY, and an
array is counted from '0', whereas our months are counted 1 to 12. So
array-month 0 is January, array-month 1 is February, and so on.

Jonathan Gold
jonnygee@p...

> -----Original Message-----
> From: digi [mailto:digitalsy@h...]
> Sent: Thursday, April 11, 2002 6:16 PM
> To: Beginning Java
> Subject: [beginning_java] Chap4 question 4 beginning java 2 jdsk 1.3
>
>
> Ok well here i am struggling away with these exercises....I get what has
> to be done, and I write it down and go step by step however i
> just come to
> a blockade when it comes to writing the code...
>
> So i looked at the answers the code that i downloaded here and there's a
> part that doesn't make sense (to me)
>
> // Generate a set of arbitrary dates in this century - 1/1/1900 to
> 31/12/1999
>     for(int i = 0; i < dates.length; i++)
>     {
>       year = (int)(100.0*Math.random());                //
> Generate year 0
> to 99 inclusive
>       month = (int)(12.0*Math.random()) + 1;            // Generate month
> 1 to 12 inclusive
>
>       // Generate random date in the month
>       if((year>0) && (year % 4 == 0) && (month == 2))   // if it's
> February in a leap year
> 	day = (int)((daysInMonth[month-1] + 1.0)*Math.random()) + 1;  //
> Date can be 1 to 29
>       else	                                                      //
> Otherwise
> 	day = (int)(daysInMonth[month-1]*Math.random()) + 1;          //
> as normal
>
> --------------
> why is it that if it's a leap year, february in the if we do daysInMonth
> [month-1] why minus 1? that won't give us the proper days in february
> and for the else, the same deal...however if i removed the -1 from both
> square brackets i would get an error when i try to run it.
>
> Please explain someone
>
> -Julian
> ---
> Do you need true END-TO-END (e2e) Java Messaging (JMS)?  Softwired
> offers industry's ONLY complete 100% JMS messaging solutions for your
> needs TODAY.
> Visit
> http://adtracking.wrox.com/track.asp?x=p2p%2Fe%2Fjava%2Dsoftwired&
url=www.softwired-inc.com Our unique product range includes: iBus//Mobile
(wireless data),
iBus//MessageBus (IP Multicast), iBus//MessageServer (store and forward)
and much more!


Message #5 by "digi" <digitalsy@h...> on Fri, 12 Apr 2002 01:16:10
Ok well here i am struggling away with these exercises....I get what has 
to be done, and I write it down and go step by step however i just come to 
a blockade when it comes to writing the code...

So i looked at the answers the code that i downloaded here and there's a 
part that doesn't make sense (to me)

// Generate a set of arbitrary dates in this century - 1/1/1900 to 
31/12/1999
    for(int i = 0; i < dates.length; i++)
    {
      year = (int)(100.0*Math.random());                // Generate year 0 
to 99 inclusive
      month = (int)(12.0*Math.random()) + 1;            // Generate month 
1 to 12 inclusive

      // Generate random date in the month
      if((year>0) && (year % 4 == 0) && (month == 2))   // if it's 
February in a leap year
	day = (int)((daysInMonth[month-1] + 1.0)*Math.random()) + 1;  // 
Date can be 1 to 29
      else	                                                      // 
Otherwise 
	day = (int)(daysInMonth[month-1]*Math.random()) + 1;          // 
as normal

--------------
why is it that if it's a leap year, february in the if we do daysInMonth
[month-1] why minus 1? that won't give us the proper days in february
and for the else, the same deal...however if i removed the -1 from both 
square brackets i would get an error when i try to run it.

Please explain someone

-Julian
Message #6 by "digi" <digitalsy@h...> on Fri, 12 Apr 2002 02:43:35
> Julian, I think this is because we are referencing into an ARRAY, and an
array is counted from '0', whereas our months are counted 1 to 12. So
array-month 0 is January, array-month 1 is February, and so on.

Jonathan Gold
jonnygee@p...

> -----Original Message-----
> From: digi [mailto:digitalsy@h...]
> Sent: Thursday, April 11, 2002 6:16 PM
> To: Beginning Java
> Subject: [beginning_java] Chap4 question 4 beginning java 2 jdsk 1.3
>
>
> Ok well here i am struggling away with these exercises....I get what has
> to be done, and I write it down and go step by step however i
> just come to
> a blockade when it comes to writing the code...
>
> So i looked at the answers the code that i downloaded here and there's a
> part that doesn't make sense (to me)
>
> // Generate a set of arbitrary dates in this century - 1/1/1900 to
> 31/12/1999
>     for(int i = 0; i < dates.length; i++)
>     {
>       year = (int)(100.0*Math.random());                //
> Generate year 0
> to 99 inclusive
>       month = (int)(12.0*Math.random()) + 1;            // Generate month
> 1 to 12 inclusive
>
>       // Generate random date in the month
>       if((year>0) && (year % 4 == 0) && (month == 2))   // if it's
> February in a leap year
> 	day = (int)((daysInMonth[month-1] + 1.0)*Math.random()) + 1;  //
> Date can be 1 to 29
>       else	                                                      //
> Otherwise
> 	day = (int)(daysInMonth[month-1]*Math.random()) + 1;          //
> as normal
>
> --------------
> why is it that if it's a leap year, february in the if we do daysInMonth
> [month-1] why minus 1? that won't give us the proper days in february
> and for the else, the same deal...however if i removed the -1 from both
> square brackets i would get an error when i try to run it.
>
> Please explain someone
>
> -Julian
> ---
> Do you need true END-TO-END (e2e) Java Messaging (JMS)?  Softwired
> offers industry's ONLY complete 100% JMS messaging solutions for your
> needs TODAY.
> Visit
> http://adtracking.wrox.com/track.asp?x=p2p%2Fe%2Fjava%2Dsoftwired&
url=www.softwired-inc.com Our unique product range includes: iBus//Mobile
(wireless data),
iBus//MessageBus (IP Multicast), iBus//MessageServer (store and forward)
and much more!


Doh! You're right...damn it's little things like that we gotta watch out 
for. Wow...and i even knew that, i just overlooked it. Maybe i'm not 
getting enuff sleep these days...heh...well i'll keep truckin...these 
examples are really intense.

Thanks by the way :)
-Julian

  Return to Index