Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

what is wrong with the code??

+3 votes
asked Jul 8, 2021 by Kenjie Ballesteros (150 points)

the error is 

main.cs(21,12): error CS1525: Unexpected symbol `{'
main.cs(58,0): error CS1525: Unexpected symbol `}'

and I have been searching for the unexpected symbol for the past few minutes, yet I can't find it. Here's the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Grock
{
    class Program
    {
        static void Main(string[] args)
        {
            bool isRunning = true;
            string command = "";
            Vault vault = new Vault("Emerald", 100);
            Prison prison = new Prison("David Panpa", "Reginald Copperbottom");
            PlansBook plansBook = new PlansBook("Reginald Copperbottom", "Defeat the Government", "Launch an Orbit Station");
            Book shrek = new Book("Shrek", "William Steig", 30)
            
            while (isRunning)
            {
                command = Console.ReadLine();
                
                if (command == "/help")
                {
                    Console.WriteLine("Commands:");
                    Console.WriteLine("/vault");
                    Console.WriteLine("/prison");
                    Console.WriteLine("/plans");
                    Console.WriteLine("/book");
                }
                else if (command == "/vault")
                {
                    Console.WriteLine("Jewel: " + vault.jewel);
                    Console.WriteLine("Money: " + vault.money + "$");
                }
                else if (command == "/prison")
                {
                    Console.WriteLine("Captured: " + prison.captured);
                    Console.WriteLine("Capturer: " + prison.capturers);
                }
                else if (command == "/plans")
                {
                    Console.WriteLine("Author: " + plansBook.author);
                    Console.WriteLine("Plans: ");
                    Console.WriteLine(plansBook.plan1);
                    Console.WriteLine(plansBook.plan2);
                }
                else if (command == "/book")
                {
                    Console.WriteLine("Title: " + shrek.title);
                    Console.WriteLine("Author: " + shrek.author);
                    Console.WriteLine("Pages: " + shrek.pages);
                }
            }
        }
    }
}

1 Answer

0 votes
answered Sep 23, 2021 by Peter Minarik (86,040 points)

Missing a semicolon (;) from the end of line 18:

Book shrek = new Book("Shrek", "William Steig", 30);

Furthermore, all the classes are not provided:

  • Vault
  • Prison
  • PlansBook
  • Book

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...