Skip to content

Commit

Permalink
Added alter table
Browse files Browse the repository at this point in the history
  • Loading branch information
Oia20 committed Apr 26, 2024
1 parent 5191123 commit d7b4252
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion CropSQL/Pages/Components/Terminal.razor
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,17 @@
"Let's start by creating your farm with 'CREATE DATABASE' followed by the name of our farm, lets name ours 'sqland', followed by a semi-colon don't forget the semi-colon, this is how sql knows where your command ends.",
"We need to tell SQL which Database we are using, do this by saying 'USE' followed by our farm name.",
"You need a table to store the crops in your field. Create a table with 'CREATE TABLE' followed by the table name, we will name ours 'crops' then open a parentheses '('inside of your table you can specify columns, and what datatype goes into them. This will make more sense later in the game, but for now, lets create a column named Crop with a data type of varchar(20) which is a word with a max of 20 characters. Then an Amount column which takes and int, and a Word column which also takes an int.",
"Oops, it looks like we forgot to add a column for how much our Crops are worth! Not to worry, SQL gives us a command for that. 'ALTER TABLE tableName' followed by ADD columnName datatype"
"Oops, it looks like we forgot to add a column for how much our Crops are worth! Not to worry, SQL gives us a command for that. 'ALTER TABLE tableName' followed by ADD columnName datatype",
"Hello"
]);
private List<string[]> codeSample = new List<string[]>
{
new string[] { "CREATE DATABASE sqland;" },
new string[] { "USE sqland;" },
new string[] { "CREATE TABLE crops (", "crop varchar(20),", "amount int", ");"},
new string[] { "ALTER TABLE crops", "ADD worth int;" },
new string[] { "ALTER TABLE crops", "ADD worth int;" }

};
private void ExecuteCommand()
{
Expand All @@ -124,6 +127,8 @@
currentCommand.ForEach(Console.WriteLine);
currentCommand = currentCommand.SelectMany(command => command.Split(" ")).ToList();
currentCommand.ForEach(Console.WriteLine);
currentCommand.RemoveAll(string.IsNullOrEmpty);


switch (termNum) {
case 1:
Expand Down Expand Up @@ -164,6 +169,24 @@
}
break;
case 4:
if (currentCommand.Count > 5 &&
currentCommand[0].ToUpper() == "ALTER" &&
currentCommand[1].ToUpper() == "TABLE" &&
currentCommand[2].ToUpper() == "CROPS" &&
currentCommand[3].ToUpper() == "ADD" &&
currentCommand[4].ToUpper() == "WORTH" &&
currentCommand[5].ToUpper().Contains("INT")
)
{
terminalOutput.Add("CropSQL> Anotha one! Column Added To Table!");
termNum++;
}
else
{
terminalOutput.Add("CropSQL> Incorrect Command");
}
break;
case 5:

break;
}
Expand Down

0 comments on commit d7b4252

Please sign in to comment.