Advertisement
Guest User

Untitled

a guest
May 13th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. //here is the method in class A that populates its own entities
  2. public ReadProximityEvents(String file)
  3. {
  4.     FileStream fs = File.OpenRead(file);
  5.     reader = new BinaryReader(fs);
  6.  
  7.     int type = reader.ReadInt32();
  8.     Console.WriteLine(type);
  9.  
  10.     for (int x = 0; x < type; x++)
  11.     {
  12.         entities.Add("");
  13.  
  14.         while (true)
  15.         {
  16.             char next = reader.ReadChar();
  17.  
  18.             if (next != '|')
  19.             {
  20.                 entities[x] += next;
  21.             }
  22.             else
  23.             {
  24.                 break;
  25.             }
  26.         }
  27.  
  28.         entities[x] = entities[x].Trim().ToLower();
  29.         Console.WriteLine(entities[x]);
  30.  
  31.     //this method outputs:
  32.     //3
  33.    //pencil
  34.     //smartboard
  35.    //tabletc
  36.     }
  37. }
  38.  
  39. //here is class B that is instantiated with the entities obtained above
  40. public class Parser
  41. {
  42.     List<String> entities = new List<String>();
  43.  
  44.     public Parser(List<String> entities)
  45.     {
  46.         this.entities = entities;
  47.     }
  48.  
  49.     public bool validate()
  50.     {
  51.         for(int x = 0; x < entities.Count; x++)
  52.         {
  53.             Console.WriteLine(entities[x] + " " +  ("a pencil g smartboard tabletc ".IndexOf(entities[x])));
  54.  
  55.         //outputs
  56.         //pencil -1
  57.         //smartboard 11
  58.        //tabletc -1
  59.         }
  60.  
  61.         return true;
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement