• Post Reply Bookmark Topic Watch Topic
  • New Topic

Quick Question on a Numerology Report  RSS feed

 
Ti Ru
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a post from http://www.dreamincode.net/forums/topic/143081-numerology-report/ - I couldnt figure out how to quote it. Basically what i am trying to figure out is how to make required user input in the format, mm / dd / yyyy with spaces before and after the dashes.




Thanks!
 
Steve Fahlbusch
Bartender
Posts: 612
7
Mac OS X Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok,

Do you really want the user to input MMb/bDDb/bYYYY (where b is blank or space)

OR

Do you simply want the report to output as above?


If you want to user to input spaces, why?

-steve
 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ti Ru wrote:Basically what i am trying to figure out is how to make required user input in the format, mm / dd / yyyy with spaces before and after the dashes.

That code assumes there will be no spaces around the slashes (not dashes).
So if you want the user to enter spaces then you need to change lines 32 - 44 of your code.
The length of the line will no longer be 10 and you will have to check for spaces either side of where you currently set the values of symbol and symbol2.

Having said all that, you would actually be better off looking at the SimpleDateFormat class which will do all of this for you.
 
Ti Ru
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its a requirment for the class. How would i go about accounting for the spaces before and after the dashes? Would the below code work?

mm / dd / yyyy
012345678910111213


 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch and well done finding the code button. But your indentation is inconsistent and you have too many blank lines. We have some suggestions about indentation, etc. You will find more help if you look at the first and second links in this previous post.

I shall see if I can improve your indentation, as well as breaking the longer lines, so you can see the way to do it.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried to improve the indentation.
Why are all your methods static? you should create a field for date (or day month year) and use non‑static methods.
Don't call the Birthday method so often. Make the check method return a boolean for valid date, and you can then call the method once in a loop. The methods should be called birthday and check, by the way.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ti Ru wrote:Would the below code work?

Have you tested it ?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!