From 15b09cdbf48f8feec96cefd7e0930f4528e629d6 Mon Sep 17 00:00:00 2001 From: Jacob <92279567+Oia20@users.noreply.github.com> Date: Fri, 26 Apr 2024 22:17:10 -0500 Subject: [PATCH] Step 10 finished. --- CropSQL/Pages/Components/Terminal.razor | 34 ++++++++++++++++++------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/CropSQL/Pages/Components/Terminal.razor b/CropSQL/Pages/Components/Terminal.razor index 222d70b..7efca01 100644 --- a/CropSQL/Pages/Components/Terminal.razor +++ b/CropSQL/Pages/Components/Terminal.razor @@ -12,9 +12,9 @@
  • 6. Insert Into
  • 7. Select *
  • 8. Alter Again
  • -
  • 9. Create Table2
  • -
  • 10. Select *
  • -
  • 11. Select *
  • +
  • 9. Create Table 2
  • +
  • 10. Update, Set
  • +
  • 11. Insert Into 2
  • 12. Select *
  • 13. Select *
  • 14. Select *
  • @@ -36,8 +36,8 @@
  • 7. Select *
  • 8. Alter Again
  • 9. Create Table2
  • -
  • 10. Select *
  • -
  • 11. Select *
  • +
  • 10. Update, Set
  • +
  • 11. Insert Into 2
  • 12. Select *
  • 13. Select *
  • 14. Select *
  • @@ -139,9 +139,9 @@ "Next it's time that we plant some crops. Let's start with the worst one of all, Carrots! in SQL we do this with the 'INSERT INTO' command followed by the table name. Then in parentheses we specify which columns we want to modify, in our case we want to modify all columns 'INSERT INTO Crops (Crop, Amount, Worth)' Then we use the 'VALUES ()' command to insert into columns Let's plant carrot, 5, 2. Planting 5 carrots at a worth of 2.", "Let's now view our planted crops! Do so with the 'SELECT' keyword, then a 'a' which means all columns, then 'FROM' lastly the name of the table;", "We want to add a column to our table for the product of amount * worth to figure out how much our crops are worth. We can do this with 'ALTER TABLE crops' then 'ADD total int;'", - "Hello", - "Hello", - "Hello", + "Let's start preparing to sell our crops! first lets create a new table named sold, which takes a crop with datatype of varchar(20), and an int of total.", + "Now let's calculate the total value of our crops with the 'UPDATE' command, followed by the table name. Then use the 'SET command followed by the column you want to alter (total) set to = the product of the amount and worth columns'", + "It's time that we sell our crops! Let's insert from our crops column into our sold column.", "Hello", "Hello", "Hello", @@ -161,7 +161,7 @@ new string[] { "SELECT * FROM crops;" }, new string[] { "ALTER TABLE crops", "ADD total int;" }, new string[] { "CREATE TABLE sold (", "crop varchar(20),", "total int", ");" }, - new string[] { "ALTER TABLE crops", "ADD worth int;" }, + new string[] { "UPDATE crops", "SET total = amount * worth;" }, new string[] { "ALTER TABLE crops", "ADD worth int;" }, new string[] { "ALTER TABLE crops", "ADD worth int;" }, new string[] { "ALTER TABLE crops", "ADD worth int;" }, @@ -345,7 +345,23 @@ break; case 10: + if (currentCommand[0].ToUpper().Contains("UPDATE") && + currentCommand[1].ToUpper().Contains("CROPS") && + currentCommand[2].ToUpper().Contains("SET") && + currentCommand.Any(s => s.ToUpper().Contains("TOTAL")) && + currentCommand.Any(s => s.ToUpper().Contains("AMOUNT")) && + currentCommand.Any(s => s.ToUpper().Contains("*")) && + currentCommand.Any(s => s.ToUpper().Contains("WORTH")) + ) + { + terminalOutput.Add("CropSQL> Very good! The crops table now has a total column which is set to be the product of worth and amount columns!"); + termNum++; + } + else + { + terminalOutput.Add("CropSQL> Incorrect Command"); + } break; case 11: