• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to do the setter functions  RSS feed

 
Shal Lango
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Part is an object that has four values associated with it:

name - A textual name
number - an alphanumberic sequence that may contain hyphens
ncage - A five character alphanumeric code for a business of the form NNNNN
niin - a 13 digit code of the form XXXX-XX-XXX-XXXX
Create the class and its members, accessors, and mutators.

I'm not sure how to do the setter functions to make the number/ncage/niin accept those kind of values. Any tips? So far I have:


Thanks
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need setters at all? That code will work.
There are some stylistic things: variables shou‍ld not start with CapitalLetters: name not Name.
There shou‍ld be a CapitalLetter after set in the names of methods. Not getnCage but getNCage.
Why do your instructions say niin and your code nIin?
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only declare one field per line. Give each field its own declaration.
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming it's part of the requirements (which ask for mutators).

I guess the issue is the validation?
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:. . . part of the requirements (which ask for mutators). . . .
I missed that bit. Sorry. It is surprisingly hard to find something simple about the bean pattern on the net.
What do you know about setXXX methods?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!