• Post Reply Bookmark Topic Watch Topic
  • New Topic

Combination and Locker project  RSS feed

 
Mateusz Filipowicz
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, I was wondering you can help me tackle on this project. I got a high school student with locker number, name assigned, number of books in the locker, and combination lock 3 numbers between 0 - 39. Each of the classes are including two constructors, setters and getters, and print out with attributes.

Do I need to specify the range ? If so, do I need to use array's instead?




 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mateusz Filipowicz wrote: Do I need to specify the range ? If so, do I need to use array's instead?

I don't think your questions are very clear...a range for WHAT exactly? use arrays instead of WHAT?
 
Mateusz Filipowicz
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The range of numbers for combination lock 0-39, The combinationlock class uses string combinationI
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mateusz Filipowicz wrote:The range of numbers for combination lock 0-39, The combinationlock class uses string combinationI

Why a String? Or indeed a 'char'? These things are numbers, or values, even if they might be presented as something else.

Have a look at the StringsAreBad page. It might give you a few pointers.

Winston
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mateusz Filipowicz wrote:The range of numbers for combination lock 0-39, The combinationlock class uses string combinationI

something else you should read is the StopCoding page. You shouldn't start off by thinking "I need an array, I need a String...".

You should start off thinking in general terms..."i need to pass a combination to a lock"..."I need to assign a locker number", "I need to be able to lock a lock"etc.

THEN you start refining those steps.

then you start coding those in teeny, tiny bits. You compile and test your code about 20 times more often that you think you should.

It looks to me like you sat down, wrote a bunch of code, and then started trying to figure out how to make it work...that is 100% backwards.
 
Mateusz Filipowicz
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep. You're right fred !!! Thanks guys, now I see the angle to approach this assgn.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!