Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2681

Re: Need to create a default constructor that generates 2 random questions. I'm fairly new to programming

Newsgroups comp.lang.java.help
Date 2013-04-14 18:48 -0700
References <063e6687-49a9-49d6-b7d4-29fd86115329@googlegroups.com> <qc3lm85qcq7usmh1ph9an44j2mskps43o1@4ax.com> <nospam-559D38.13302014042013@news.aioe.org> <kkeu13$l7i$1@dont-email.me>
Message-ID <aee3a436-3a9b-4631-9c12-5838ed707b96@googlegroups.com> (permalink)
Subject Re: Need to create a default constructor that generates 2 random questions. I'm fairly new to programming
From Lew <lewbloch@gmail.com>

Show all headers | View raw


markspace wrote:
> I think using a ctor for the OP's problem is fine.  We're definitely 

Bad habits begun early are the hardest to break later.

> getting to the point here where there's a surfeit of advice.  I object 
> to file I/O in a ctor, it's gauche.  Almost anything else is fine, as 

Constructors are for construction.

Anything that can logically be considered necessary for the object to 
be in a "constructed" state is fair game, but certain things (like I/O)
incur extra responsibility. So it's wise to design your types so that 
weird stuff is not needed to establish the "constructed" state.

> long as you adhere to best practice and avoid things like this-escape 
> and so forth.  The OP's ctor is probably about 7 lines of code.  That's 
> pretty trivial for a ctor, imo.

Maybe trivial, but short, easy things are the best for starting good 
practices.

> The OP's main problem is he doesn't seem to understand how to construct 
> his if-statement to give him the output he needs.  Well, that and a 
> certain newbishness using the language overall, but that's to be expected.

-- 
Lew

Back to comp.lang.java.help | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Need to create a default constructor that generates 2 random questions. I'm fairly new to programming sunnyaleem@gmail.com - 2013-04-12 16:11 -0700
  Re: Need to create a default constructor that generates 2 random questions. I'm fairly new to programming Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-04-12 20:26 -0400
  Re: Need to create a default constructor that generates 2 random questions. I'm fairly new to programming Roedy Green <see_website@mindprod.com.invalid> - 2013-04-14 04:07 -0700
    Re: Need to create a default constructor that generates 2 random questions. I'm fairly new to programming "John B. Matthews" <nospam@nospam.invalid> - 2013-04-14 13:30 -0400
      Re: Need to create a default constructor that generates 2 random questions. I'm fairly new to programming markspace <markspace@nospam.nospam> - 2013-04-14 11:57 -0700
        Re: Need to create a default constructor that generates 2 random questions. I'm fairly new to programming Lew <lewbloch@gmail.com> - 2013-04-14 18:48 -0700

csiph-web