Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //here is the method in class A that populates its own entities
- public ReadProximityEvents(String file)
- {
- FileStream fs = File.OpenRead(file);
- reader = new BinaryReader(fs);
- int type = reader.ReadInt32();
- Console.WriteLine(type);
- for (int x = 0; x < type; x++)
- {
- entities.Add("");
- while (true)
- {
- char next = reader.ReadChar();
- if (next != '|')
- {
- entities[x] += next;
- }
- else
- {
- break;
- }
- }
- entities[x] = entities[x].Trim().ToLower();
- Console.WriteLine(entities[x]);
- //this method outputs:
- //3
- //pencil
- //smartboard
- //tabletc
- }
- }
- //here is class B that is instantiated with the entities obtained above
- public class Parser
- {
- List<String> entities = new List<String>();
- public Parser(List<String> entities)
- {
- this.entities = entities;
- }
- public bool validate()
- {
- for(int x = 0; x < entities.Count; x++)
- {
- Console.WriteLine(entities[x] + " " + ("a pencil g smartboard tabletc ".IndexOf(entities[x])));
- //outputs
- //pencil -1
- //smartboard 11
- //tabletc -1
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement