• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Array of objects

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 8504
610
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 8504
610
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 14496
325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Everybody's invited. Except this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic