public static TikTok Parse(string line) { string[] words = line.Split('\t'); string n_id = words[0]; string n_originator = words[1]; int n_length = Convert.ToInt32(words[2]); string n_hashTag = words[3]; Audience n_audience = (Audience)Enum.Parse(typeof(Audience), words[4]); TikTok tikTokObject = new TikTok(n_id, n_originator, n_length, n_hashTag, n_audience); return(tikTokObject); }
public static void Initialize() { //Creates about 5 tiktoks objects and add them to the tiktok collection. TikTok T = new TikTok("TylerSwift", 300, "music", Audience.World); TikTok E = new TikTok("EmmaWatson", 210, "movie", Audience.Group); TikTok J = new TikTok("JessiJ", 410, "movie", Audience.World); TikTok A = new TikTok("AriannaGrande", 40, "music", Audience.Special); TikTok K = new TikTok("KatePerry", 30, "movie", Audience.Special); TIKTOKS.Add(T); TIKTOKS.Add(E); TIKTOKS.Add(J); TIKTOKS.Add(A); TIKTOKS.Add(K); }
static TikTokManager() { // Initialize the TIKTOKS field to a new list of tiktok TIKTOKS = new List <TikTok>(); //Opens the file specified by the filename field for reading TextReader reader = new StreamReader(FILENAME); string line = reader.ReadLine(); // Using a looping structure it does the following: //This is repeated until the input from the file is empty (null). while (line != null) { //Reads one line from the file // Passes this line to the static Parse() method of the TikTok class to create a tiktok object. // The resulting object is added to the tiktok collection. TIKTOKS.Add(TikTok.Parse(line)); line = reader.ReadLine(); } reader.Close(); }