• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Piping

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Goodbye moon men. Hello tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic