• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Filters and Pipes (problem)

 
Ranch Hand
Posts: 86
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm new in this kind of architecture and I'm finding some obstacles. I have a project with 3 classes. The goal is to take a list of names from an input file and store them in two other files according their status(Pass or non-Pass). Pass, is an input where has a specific ID and one of two(or both two) specific numbers. Also, if an input doesn't has the specific ID but has a specific 3rd number and one of two specific numbers above then is Pass too.

For example:
specific ID=xxxx - specificNum#1=1234 - specificNum#2=5678 - specificNum#3=9999
input#1: xxxx - 1234 - 0000 -->Pass
input#2: xxxx - 3333 - 0000 -->non-Pass
input#3: xxxx - 1234 - 5678 -->Pass
input#4: zzzz - 1234 - 0000 -->non-Pass
input#5: aaaa - 1234 - 9999 -->Pass
etc.

So my main class scanning the input line and searching for the specific ID. Second class taking the line and searching for specific number. Third class taking the line and writing it to the appropriate text file.

In main class also created three objects of 2nd class, each one has different searching numbers and two 3rd class, pass and non-pass

My first question is, I have to create another 2nd class that will doing different things that current does, or I can solve it with just 3 classes?

Thank you,
Pan Niko
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To understand you requirement correctly -
1. You read data from a file.
2. You check the read line against a pattern.
3. If the line passes with a pattern, write it to a different file (call "Passed_Input.txt").
4. If the line fails with all the pattern, write it to a different file (call "Failed_Input.txt").

If this is the requirement, then I might write the code like -
1. Form a regex pattern that will match the input line read from the file.
2. Read the input file line by line and compare against the regex.
3. If it matches add it to a buffer of matched Ids.
4. If it fails add it to a buffer of failed Ids.
5. Write the buffer with matched id's into Passed_Input.txt and the other to the other file.

My first question is, I have to create another 2nd class that will doing different things that current does, or I can solve it with just 3 classes?


To do different things, why you go for a class. You can have different methods that does different things in the same class.

Can you show the classes you have tried so far?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic