Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This assignment attempts to model this social phenomenon. It involves an enum and two main classes: Audience, TikTok and TiktokManager. You will load a set

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed

This assignment attempts to model this social phenomenon. It involves an enum and two main classes: Audience, TikTok and TiktokManager. You will load a set of tikoks from a local file into a List collection. You will perform some simple queries on this collection. The Tikok and the TikokManager classes must be in separate files and must not be in the Program.cs file. The Audience enum may be implemented in the Tiktok.cs file. The Audience Enum [5 marks] This enum specifies the intended audience for this tiktok. It consists of three constants as shown in the table below: Audience Enum Constants World Group Special Acti do to The TikTok Class The TikTok class consist of ten members that include two static ones (the members decorated with the $ symbol). You will implement this and all of the classes in Visual Studio. A short description of the class members is given below: TikTok Class Fields -$ _ID :int Properties + Originator + Length + HashTag + Audience : string : int : string : Audience : string + Id Methods : string, : int, : string, : Audience) + + constructorTikTok ( originator length hashTag audience constructorTikTok ( id originator length hashTag audience + ToString() +$ Parse(line : string) : string, : string, : string, : string, : string) : string : TikTok The $ symbol is used to denote that this member belongs to the type rather than a specific object Ac and you must use the type to access that member. Go to Fields (15 points]: 1. _ID- this private field is a class variable, it represents the number to be used in setting theid of this item. Properties (10 points]: All of the properties are readonly and are self-explanatory. 1. Originator - this property is a string representing the originator of this tikok. The getter is public and the setter is absent. 2. Length - this property is an int representing the length in second recipient of this tikok. The getter is public and the setter is absent. 3. HashTag - this property is a string representing the hashtag of this tikok. The getter is public and the setter is absent. 4. Audience - this property is a string representing the distribution of this tikok. The getter is public and the setter is absent. 5. Id - this property is a string representing the id of this tikok. The getter is public and the setter is absent. This is used to uniquely identify a tikok. Constructors [20 points]: 1. public TikTok (string originator, int length, string hashTag, Audience audience) - This constructor does the following: This is an example of constructor overloading a. Assigns the arguments to the appropriate properties. b. Sets the Id property using the class variable _ID. After the Id property is set, the _ID is then incremented so that the next assignment will be unique. (see description of Id above) Activa C. will be unique. (see description of Id above) 2. private TikTok(string id, string originator, string length, string hashTag, string audience) - This is called by the static TikTok Parse(string) method. This constructor does the following: a. Assigns the arguments to the appropriate properties. Methods (10 points]: 1. public override string ToString() - This method overrides the same method of the object class. It does not take any parameter but return a string representation of itself. You decide on the format for the output. 2. public static TikTok Parse(string line) - This is a public class method that takes a string argument and returns a TikTok object. It is used to create a TikTok object when loading the TikToks from a file. The argument represents a single line of input read from the file. This method does the following: a. Uses the method of the string class is to chunk the input into four strings. The default delimiter for the Split() method is a space, however in this case the delimiter should be a tab. To specify an argument for the Split() method use Actis the following code: Split('It'); Go to b. Invokes the five arguments constructor. Because all the arguments are string, it is easy to inter-change the order. You need to examine the text file to make sure that you are sending the arguments to the constructor in the required order. Return the result of the above invocation C. The TikTokManager Class This static class consist of five static members. You will also implement this in Visual Studio. A short description of the class members is given below: $ TikTokManager Static Class Fields - $ TIKTOKS - $FILENAME : List : string wwwww Methods $ TikTokManager() +$ Initialize() : void +$ Show) : void +$ Show (hashtag : string) : void +$ Show(length : int) : void +$ Show(audience : Audience) : void ALL MEMBERS ARE STATIC! Fields [15 points]: 1. TIKTOKS - this private field is a class variable; it is a collection of all the tiktoks in the system. It is initialized and populated in the static constructor. 2. FILENAME this private field is a class variable; it represents the name of the file that contains all the tiktoks. It is used in the static constructor to read in the tiktoks. You will have to set this to the name of file that has the information about the tiktoks. A static constructor does not take any arguments, nor does it require any Constructor: accessibility modifier. Infact specifying one 1. static TikTokManager() - This is the will raise a compiler error static constructor. It does not require any It is called before any member is accessed parameter. This constructor does the and never ever again. following: Initialize the TIKTOKS field to a new list of tiktok b. Opens the file specified by the filename field for reading Using a looping structure it does the following: i. Reads one line from the file. ii. Passes this line to the static Parse() method of the TikTok class to create a tiktok object. iii. The resulting object is added to the tiktok collection. iv. This is repeated until the input from the file is empty (null). a. c. Methods [: 1. public static void Initialize() - This class method it used to facilitate the development of this project. It will not be used in the production This will be used to test your code in the event you cannot figure out the file reading part. code, just while developing. This method does the following: a. Assigns the TIKOKS field b. Creates about 5 tiktoks objects and add them to the tiktok collection. 2. public static void show() - This is a public class method that does not take any argument This is good example of method that does not return a value. It displays all the overloading, i.e. methods with the same name. tiktoks in the collection. 3. public static void show(string tag) - This is a public class method that takes a string argument that does not return a value. It displays all the tiktoks with hashTag matching the argument. This comparison must be case in-sensitive. 4. public static void show(int length) - This is a public class method that takes an int argument that does not return a value. It displays all the tiktoks with length greater than the argument. 5. public static void show(Audience audience) - This is a public class method that takes an int argument that does not return a value. It displays all the tiktoks with audience matching the argument. Testing (10 points] In your test harness (the Main() method in the Program Class), write the code to test all the methods of the TikTakManager class including the Initialize() method. When testing with the supplied file copy the file to bin\Debug folder. - group tiktoks - Notepad File Edit Format View Help 500000 abhi 20 group covid 500001 sameer 19 group covid 500002 joan 24 group summer heat 500003 ajay 15 world bars 500004 carl 21 world park 500005 hema 22 special park 500006 jerry 20 group bars 500007 jen 20 world covid 500008 abi 14 park 500009 dave 19 special summer 500010 fred 16 group covid 500011 dave 24 group summer heat 500012 abby 20 world bars 500013 prataap 21 world park 500014 brad 18 special park 500015 rahul 19 group bars 500016 abhi 17 world covid 500017 suresh 19 group covid 500018 shivani 24 group summer heat 500019 abram 15 world bars 500020 chandra 21 world park 500021 rishi 22 special park 500022 ranbir 20 group bars 500023 vinod 20 world covid 500024 rahul 14 group park 500025 bindu 19 special summer 500026 yasmin 16 group covid 500027 preeti 24 group summer heat 500028 Sanjay 20 world bars 500029 hema 21 world park 500030 rishi 18 special park 500031 joan 24 group summer heat 500032 ajay 15 world bars 500033 abhi 21 world social distancing 500034 shivani 22 special park bars 500035 jerry 20 500036 jen 20 500037 abi 14 500038 dave 19 500039 fred 16 500040 ajay 24 500041 abby 20 500042 prataap 21 500043 brad 18 500044 rahul 19 500045 abhi 17 500046 suresh 19 500047 shivani 24 500048 abram 15 500049 ranbir 21 500050 rishi 22 group covid world covid group park special music group covid group concert world world toronto special park group college world covid group summer summer heat world bars world park special covid group Use C# Console App (.NET Framework) C#

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 15th International Conference Dexa 2004 Zaragoza Spain August 30 September 3 2004 Proceedings Lncs 3180

Authors: Fernando Galindo ,Makoto Takizawa ,Roland Traunmuller

2004th Edition

3540229361, 978-3540229360

More Books

Students also viewed these Databases questions

Question

e. What are notable achievements of the group?

Answered: 1 week ago