• Post Reply Bookmark Topic Watch Topic
  • New Topic

Array of objects  RSS feed

 
Thanraj Danz
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


i wanted to know what parameter is being passed into the method printDeck and printCard and how its accessed inside the method ??

P.S Clear Explaination
 
Paweł Baczyński
Bartender
Posts: 2054
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to improve your indentation.

The parameter passed to printDeck is a reference to card[], an array of type card.
The parameter passed to printCard is a reference to card.

What do you mean by how its accessed inside the method?
 
Liutauras Vilda
Marshal
Posts: 4666
320
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanraj Danz wrote:P.S Clear Explaination
As you been already told, you should worry about clearly indenting your code first, then you could expect clear explanations from folks around. Anyway, I copied your code and improved it, here is how it should look like:
 
Liutauras Vilda
Marshal
Posts: 4666
320
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some other comments:
1. You class name suppose to start with an Upper case.
2. Why you have 2 pairs of identically named variables "suit", "rank"? One of those are used locally within loop scope, and the other instance. It adds confusion with no reason.
3. Why your instance variables are not private?
4. Why your methods are static?
5. For the cards, maybe enum type would the one to use? Read about it here (<- link to read, click on it).
6. Your main method not terrible, bet also not ideal. Check this tutorial.
7. Also, the structure of your class I found difficult to read. I'd expect to see constructors first, so I'd know what to expect in case of instantiation of it, then other methods. main method ideally should be in your launcher class, in a separate source file.

Hope that helped a bit. And welcome to the Ranch
 
Stephan van Hulst
Saloon Keeper
Posts: 7821
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanraj Danz wrote:i wanted to know what parameter is being passed into the method printDeck and printCard and how its accessed inside the method ??


Just a nitpick: parameters don't get passed. You pass arguments. Parameters are the variables holding arguments.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!