SHOW:
|
|
- or go back to the newest paste.
| 1 | using System; | |
| 2 | using System.IO; | |
| 3 | using System.Text; | |
| 4 | public class Name | |
| 5 | {
| |
| 6 | public string moviename { get; set; }
| |
| 7 | public int CastSize { get; set; }
| |
| 8 | public string[] CastMembers { get; set; }
| |
| 9 | public override string ToString() | |
| 10 | {
| |
| 11 | return string.Format("film: {0} \n", moviename.ToString());
| |
| 12 | ||
| 13 | } | |
| 14 | } | |
| 15 | public class MovieData | |
| 16 | {
| |
| 17 | public int NumberOfLines = 0; | |
| 18 | public string UserInput; | |
| 19 | public void ManageData() | |
| 20 | {
| |
| 21 | - | string[] text = File.ReadAllLines(@"C:\Users\Micah Lee\Desktop\Document.rtf"); |
| 21 | + | string[] text = File.ReadAllLines(@"\Document.rtf"); |
| 22 | NumberOfLines = text.GetUpperBound(0); | |
| 23 | Name[] film = new Name[NumberOfLines]; | |
| 24 | int OurFilm = 0; | |
| 25 | for(int i = 0; i<text.Length; i++) | |
| 26 | {
| |
| 27 | film[OurFilm] = new Name(); | |
| 28 | film[OurFilm].moviename = Convert.ToString(text[i].Trim()); | |
| 29 | i++; | |
| 30 | film[OurFilm].CastSize = Convert.ToInt32(text[i].Trim()); | |
| 31 | i++; | |
| 32 | int castsize = film[OurFilm].CastSize; | |
| 33 | film[OurFilm].CastMembers = new string[castsize--]; | |
| 34 | for (int j = 0; j < film[OurFilm].CastMembers.Length; j++) | |
| 35 | {
| |
| 36 | film[OurFilm].CastMembers[j] = Convert.ToString(text[i].Trim()); | |
| 37 | i++; | |
| 38 | } | |
| 39 | i--; | |
| 40 | OurFilm++; | |
| 41 | } | |
| 42 | Console.WriteLine("To see the films your movie star has appeared in please enter his/her name: ");
| |
| 43 | UserInput = Convert.ToString(Console.ReadLine()); | |
| 44 | for(int o =0; o < film.Length; o++) | |
| 45 | {
| |
| 46 | for(int p = 0; p <film[o].CastMembers.Length; p++) | |
| 47 | {
| |
| 48 | if(UserInput == film[o].CastMembers[p]) | |
| 49 | {
| |
| 50 | Console.WriteLine(film[o].moviename); | |
| 51 | } | |
| 52 | } | |
| 53 | } | |
| 54 | } | |
| 55 | } |