• Post Reply Bookmark Topic Watch Topic
  • New Topic

Class design  RSS feed

 
Bren Reg
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,

Currently teaching myself java and am running into a few problems with designing classes and knowing what to put in them. Ive gotten my hands on the Head First Object Orientated Analysis and Design book so will be giving that a read soon but in the mean time hope someone can help.

I want to write a simple program to help me remember key points for the SCJP exam. Like a flash card with a question and answer.

I want to be able to add questions and save them to a text file or something. Could some one give me a general jist of to what classes I should have in this program.

I have a Card class with two String instance variables. One for question and one for answer. I have getter and setters for both.

I have a Deck class with an ArrayList for holding the cards. Im not quite sure what other methods to put in this class. Like should I have an addCard method? Or should that be in a seperate class??

Next I made a MainGui class that sorted out all the GUI bits. Not sure what methods tho to have in this class either. Should I have a method to set a label to the card question in the GUI class??

Sorry if i havent explained myself well. Its hard to even get across where I am gettin stuck. Any help would be great!
 
Randall Twede
Ranch Hand
Posts: 4696
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
if you are just studying for SCJP there are better ways. however i think you are just eager to write something
your basic approach is good a Card class and a Deck class. i think right now you have to think about your GUI.
you need some way to add a Card and some way to choose Cards to look at. there are a multitude of ways. buttons, menuItems, JComboBox will probably be useful
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!