This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Piping  RSS feed

 
Cheryl Scodario
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some trouble understanding piping on unix. I know it is that you give the output of a class to another class as input. For my programming assignment, I have to create an array of 52 cards in Deck (main driver) class. It prints a string version of it onto stdout. Shuffle (main driver) class reads a string version of a deck of cards from stdin and shuffles the deck, and writes the string version to stdout. However, when I am writing Shuffle class, should I use object reference to the deck then (keyword: new)? Here is part of my Shuffle class:


I am very confused because it's like if you use object reference, then what's the point of piping? If you use piping, then why use object reference? But w/o OR, I can't write a method. Thank you for any clarification.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure where the concept of pipes comes into play here. Pipes are used to tie two or more processes together on the Unix level, yet you mention only a single process (this Java program) - am I missing something?

What the code needs is that you fill the "deck" array with actual Cards objects (and yes - that involves calling "new Cards(...)" 52 times). "new Cards[52]" only creates the array that will hold the Cards objects, not the objects themselves.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!