TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maikeru Anonymous
NA
5
1.5k
Need help on my Cinema Console App. (2D Array)
Aug 18 2014 5:02 AM
My vision on the cinema app is...
• To make it remember which seats are taken regardless of where in the program you are.
• Somehow print the array in a form of "table".
like this:
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9...
and not like this
12345678912
3
456789123456...
Like the my code do now! ... sadly..
and i know there are many errors and small bump where i need Console.Clear(); and so on .. but main focus is Of course the guardians of the galaxy movie from there i can just repeat what happened in Guardians :)
but how do i get my code to remember selection of seats regardless of where in the program i am?
and how do i fix it? because now its just like a big mess for me sadly .. been staring blindly on this code for long now :(
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Biograf
{
class Program
{
static ConsoleColor Original;
static bool[,] ChosenGuardians;
static bool[,] ChosenHercules;
static bool[,] ChosenLucy;
static int[,] SeatsGuardians;
static int[,] SeatsHercules;
static int[,] SeatsLucy;
static Random RandomGuardians = new Random();
static Random RandomHercules = new Random();
static Random RandomLucy = new Random();
static void Main()
{
Hovedmenu();
}
static void Hovedmenu()
{
string UserChoice;
Console.WriteLine("\n");
Console.WriteLine("'A' - Movies");
Console.WriteLine("'B' - Prices");
Console.WriteLine("'C' - About Cinema Center");
Console.WriteLine();
Console.WriteLine("'Q' - Quit");
UserChoice = Console.ReadLine();
switch (UserChoice)
{
case "A":
case "a":
{
// Sub-Menu/or extended information space. (Needs Break; at end of code for it to work!)
Console.Clear();
Console.WriteLine("############################################################");
Console.WriteLine("########################## Movies ##########################");
Console.WriteLine("############################################################\n\n\n");
string MovieChoice;
do
{
Console.WriteLine("'A' - The Guardians of the Galaxy 2D");
Console.WriteLine("'B' - Hercules");
Console.WriteLine("'C' - Lucy");
Console.WriteLine();
Console.WriteLine("'Q' - Back");
MovieChoice = Console.ReadLine();
switch (MovieChoice)
{
case "a":
case "A":
{
GuardiansoftheGalaxy();
break;
}
case "b":
case "B":
{
Hercules();
break;
}
case "c":
case "C":
{
Lucy();
break;
}
case "q":
case "Q":
{
Hovedmenu();
Console.Clear();
break;
}
default:
{
Console.WriteLine("{0} Is Not A Valid Choice", MovieChoice);
break;
}
}
} while (MovieChoice != "Q" || MovieChoice != "q");
break;
}
case "b":
case "B":
{
Console.WriteLine("B menu");
Console.ReadLine();
break;
}
case "c":
case "C":
{
Console.WriteLine("C menu");
Console.ReadLine();
break;
}
case "q":
case "Q":
{
Console.WriteLine();
break;
}
}
}
static void GuardiansoftheGalaxy() ///////////////////////Guardians///////////////////////////////
{
string MovieChoiceOption;
do
{
Console.Clear();
Console.WriteLine("Guardians of the Galaxy 2D");
Console.WriteLine("'A' - Order Tickets");
Console.WriteLine("'B' - Watch Trailer");
Console.WriteLine("'C' - Storyline\n");
Console.WriteLine("'Q' - Back");
MovieChoiceOption = Console.ReadLine();
switch (MovieChoiceOption)
{
case "A":
case "a":
{
string SeatplacementRandomOrIndividually;
Console.Clear();
Original = Console.BackgroundColor;
ChosenGuardians = new bool[15, 20]; // alle Non-taken seats er falske og vice versa
SeatsGuardians = new int[15, 20]
{
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
};
ShowcaseSeatsGuardians();
Console.Write("\n\nHow many seats do you want to reserve?\n");
int numSeatReserveGuardians = int.Parse(Console.ReadLine());
Console.Write("How many of these are Children?\n");
int Childrens = int.Parse(Console.ReadLine());
int Adults = numSeatReserveGuardians - Childrens;
Console.WriteLine("So {0} Children(s) And {1} Adult(s)", Childrens, Adults);
Console.Write("Do you wanna choose your seats individually?\n\n'Y' - Yes\n'N' - No");
SeatplacementRandomOrIndividually = Console.ReadLine();
int[] Row = new int[numSeatReserveGuardians];
int[] Col = new int[numSeatReserveGuardians];
switch (SeatplacementRandomOrIndividually)
{
case "y":
case "Y":
{
Console.Write("Please Select Row and Column separated by a comma for each seat\n");
for(int i = 0; i < numSeatReserveGuardians; i++)
{
Console.Write("Seat {0, 2} :",i + 1);
string input = Console.ReadLine();
string[] Split = input.Split(',');
Row[i] = int.Parse(Split[0]) - 1;
Col[i] = int.Parse(Split[1]) -1;
if (!ChosenGuardians[Row[i], Col[i]])
{
ChosenGuardians[Row[i], Col[i]] = true;
}
else
{
Console.WriteLine(" Sorry seat already taken, please choose another.");
i--;
}
}
}
return;
case "n":
case "N":
{
for(int i = 0; i < numSeatReserveGuardians; i++)
{
int r = RandomGuardians.Next(0, 15);
int c = RandomGuardians.Next(0, 20);
if (!ChosenGuardians[r, c])
{
Row[i] = r;
Col[i] = c;
ChosenGuardians[r, c] = true;
}
else
{
i--;
}
}
}
Console.Clear();
ShowcaseSeatsGuardians();
break;
}
Console.ReadLine();
break;
}
case "B":
case "b":
{
Console.WriteLine("Watch Trailer");
System.Diagnostics.Process.Start("https://www.youtube.com/watch?v=2LIQ2-PZBC8");
Console.WriteLine("Press Any Key to Return...");
Console.ReadLine();
break;
}
case "C":
case "c":
{
Console.WriteLine("Storyline");
Console.WriteLine("the Storyline here");
Console.WriteLine("Press Any Key to Return...");
Console.ReadKey();
GuardiansoftheGalaxy();
break;
}
case "q":
case "Q":
{
Hovedmenu();
Console.Clear();
break;
}
default:
{
Console.WriteLine("{0} Is Not A Valid Choice", MovieChoiceOption);
break;
}
} while (MovieChoiceOption != "Q" || MovieChoiceOption != "q");
} while (MovieChoiceOption != "Q" || MovieChoiceOption != "q");
}
static void ShowcaseSeatsGuardians() ///////////////////////Guardians///////////////////////////////
{
for (int foo = 0; foo < SeatsGuardians.GetLength(0); foo++)
{
for (int bar = 0; bar < SeatsGuardians.GetLength(1); bar++)
{
SeatsGuardians[foo, bar] = 1 + bar;
if (ChosenGuardians[foo, bar])
Console.BackgroundColor = ConsoleColor.DarkRed;
else
Console.BackgroundColor = ConsoleColor.DarkGreen;
Console.Write("{0,3}", SeatsGuardians[foo, bar]);
}
}
Console.BackgroundColor = Original;
}
static void ShowPriceGuardians(int Adults,int Childrens) ///////////////////////Guardians///////////////////////////////
{
int Price = 90 * Adults + 50 * Childrens;
Console.WriteLine("Overall Price: {0} * 90 + {1} * 50 = {2}",Adults,Childrens,Price);
ShowcaseSeatsGuardians();
}
static void Hercules() ///////////////////////Hercules///////////////////////////////
{
string MovieChoiceOption;
do
{
Console.WriteLine("Hercules");
Console.WriteLine("'A' - Order Tickets");
Console.WriteLine("'B' - Watch Trailer");
Console.WriteLine("'C' - Storyline\n");
Console.WriteLine("'Q' - Back");
MovieChoiceOption = Console.ReadLine();
switch (MovieChoiceOption)
{
case "A":
case "a":
{
Console.WriteLine("Order Tickets");
Console.ReadLine();
break;
}
case "B":
case "b":
{
Console.WriteLine("Watch Trailer");
Console.ReadLine();
break;
}
case "C":
case "c":
{
Console.WriteLine("Storyline");
Console.ReadLine();
break;
}
case "q":
case "Q":
{
Hovedmenu();
Console.Clear();
break;
}
default:
{
Console.WriteLine("{0} Is Not A Valid Choice", MovieChoiceOption);
break;
}
}
} while (MovieChoiceOption != "Q" || MovieChoiceOption != "q");
}
static void Lucy()
{
string MovieChoiceOption;
do
{
Console.WriteLine("Lucy");
Console.WriteLine("'A' - Order Tickets");
Console.WriteLine("'B' - Watch Trailer");
Console.WriteLine("'C' - Storyline\n");
Console.WriteLine("'Q' - Back");
MovieChoiceOption = Console.ReadLine();
switch (MovieChoiceOption)
{
case "A":
case "a":
{
Console.WriteLine("Order Tickets");
Console.ReadLine();
break;
}
case "B":
case "b":
{
Console.WriteLine("Watch Trailer");
Console.ReadLine();
break;
}
case "C":
case "c":
{
Console.WriteLine("Storyline");
Console.ReadLine();
break;
}
case "q":
case "Q":
{
Hovedmenu();
Console.Clear();
break;
}
default:
{
Console.WriteLine("{0} Is Not A Valid Choice", MovieChoiceOption);
break;
}
}
} while (MovieChoiceOption != "Q" || MovieChoiceOption != "q");
}
}
}
Reply
Answers (
2
)
Creating an Auto Complete Field in Light Switch (1 table)
Not able to Save and Retrieve Image