Return to Snippet

Revision: 70582
at April 21, 2016 14:38 by Chedda56


Initial Code
class MainClass
	{
		public static void Main (string[] args)
		{
			dailyMenu [,] daysOfMonth = new dailyMenu[4,5];
			for (int column = 0; column < daysOfMonth.GetLength(0); column++) 
			{
				for (int row = 0; row < daysOfMonth.GetLength(1); row++) 
				{
					dailyMenu dm = new dailyMenu ();
					daysOfMonth[column,row] = dm; 
					Console.WriteLine (dm.ToString ());
				}
			} 
		} 

		public class dailyMenu  
		{
			private string day="";
			private int date = 0; 
			public string entree {get; private set;}
			private double price;
			private double calories;
		    static int initalDate=1;
			static string [] daysOfWeek= {"Monday","Tuesday","Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
			static string[] entrees = {"Beef Tenderloin Fresco", "Madagascar Filet Mignon", "Filet Mignon", " Lobster Ravioli", "Asian Infused Braised Beef", "New Age Chicken Cordon Bleu", "Short Ribs", " Beef Wellington",
				"Fajitas", "Bacon Cheeseburger", " Beef Burgandy", "Spagehetti"};
			static double [] entreePrices= { 5.99,7.99,6.99,4.50,9.99,10.29,5.67,8.99, 3.99,4.78,10,79,6.98};
			static int[] entreeMealCaloricVal= { 999,1288,770,699,450,999,1500,873, 911,1011, 777,500}; 

			public dailyMenu()
			{
				assignDate();
				GetDay();
				RandPopulate();
			}
			void assignDate()
			{
				date = initalDate;
				initalDate++;
				if (GetDay()== daysOfWeek[4]) 
				{
					initalDate += 2;
				}
			}
			void RandPopulate()
			{
				Random random = new Random();
				int randomNumber = random.Next(0,12);
				entree = entrees [randomNumber];
				price = entreePrices [randomNumber];
				calories = entreeMealCaloricVal [randomNumber];
			}
			public string GetDay() 
			{ 
				return daysOfWeek [(date % 7)-1]; 
			}
			public string Day
			{
				get{ return day;}
				set{day = value; }
			}
			public int Date
			{
				get{ return date; }
				set{ date = value; }
			}
			public string Entree
			{
				get{ return entree; }
				set{ entree = value; }
			}
			public double Price
			{
				get{ return price; }
				set{ price = value; }
			}
			public double Calories
			{
				get{ return calories; }
				set{ calories = value; }
			}
			public override string ToString ()
			{
				return string.Format ("Day of week: " + GetDay() + ", Entree: " + entree + ", Price: " + price + ", Calories: " + calories);
			}
			public string [] GetEntreeWeekDays()
			{
				
			}
			static void entreeSearch(dailyMenu [,] entrees)
			{
				Console.WriteLine ("PLease enter the entree you'd like to search for today :)");
				string response = Console.ReadLine ();
				response = response.ToUpper (); 
				for(int count=0; count<
					dailyMenu dm = entrees
				if (dm == null) 

					return;
				string[] weekDays = dm.GetEntreeWeekDays();
					

			}

Initial URL

                                

Initial Description
I am trying to write a function that accepts my 2d array as an argument , and allows my user to enter an entrée to search for . i then print out all the days that that entree is being served on.

Initial Title
Passing my 2D array as an arguement and printing all days on which an entree wil be served based on the entree entered?

Initial Tags

                                

Initial Language
C#