Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VI2
{
    class Program
    {
        private const string V = "iniciar";

        static void Main(string[] args)
        {

            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("------------------------ PIP-OS(R) 7.1.0 --------------------- ");
            System.Threading.Thread.Sleep(5000);
            Console.WriteLine("   > FREEWARE ROBCO(R)");
            System.Threading.Thread.Sleep(1000);

            Console.WriteLine("   > EXEC VERSION 41.10");
            System.Threading.Thread.Sleep(1000);

            Console.WriteLine("   > 64K RAM SYSTEM");
            System.Threading.Thread.Sleep(1000);

            Console.WriteLine("   > 4815162342 BYTES FREE");
            System.Threading.Thread.Sleep(1000);

            Console.WriteLine("   > NO HOLOTAPE FOUND");
            System.Threading.Thread.Sleep(1000);

            Console.WriteLine("   > LOAD ROM(1):DEITRIX 303");
            System.Threading.Thread.Sleep(1000);

            Console.WriteLine("");


            System.Threading.Thread.Sleep(1000);
            Console.WriteLine("> start");
            Console.WriteLine("");

            do
            {
                string choice = Console.ReadLine();

                switch (choice)
                {
                    case "iniciar":
                        {
                            Console.WriteLine(" Olá,eu sou uma demonstração de inteligência artificial criada por Ezequiel Santos");
                            Console.Title = "AI";



                            Console.WriteLine("Qual é o seu nome?");
                            string nome = Console.ReadLine();
                            Console.WriteLine("Bem vindo, " + nome + " , como poderei ajudar hoje?");



                            do
                            {




                                switch (Console.ReadLine())

                                {

                                    case "horas": // Do Something
                                        {
                                            // Display the date/time when this method got called.
                                            Console.WriteLine("São: " + DateTime.Now);
                                            // Force a garbage collection to occur for this demo.
                                            GC.Collect();
                                        }

                                        break;

                                    case "Horas": // Do Something
                                        {
                                            // Display the date/time when this method got called.
                                            Console.WriteLine("São: " + DateTime.Now);
                                            // Force a garbage collection to occur for this demo.
                                            GC.Collect();
                                        }

                                        break;

                                    case "HORAS": // Do Something
                                        {
                                            // Display the date/time when this method got called.
                                            Console.WriteLine("São: " + DateTime.Now);
                                            // Force a garbage collection to occur for this demo.
                                            GC.Collect();
                                        }

                                        break;


                                    case "Tudo bem?": // Do Something
                                        {
                                            Console.WriteLine("Sim,e contigo?");
                                        }

                                        break;

                                    case "TUDO BEM?": //Do that
                                        {
                                            Console.WriteLine("SIM E CONTIGO?");
                                        }
                                        break;

                                    case "tudo bem?": //Do that
                                        {
                                            Console.WriteLine("Sim,e contigo?");

                                        }

                                        break;

                                    case "tudo belho?": //Do that
                                        {
                                            Console.WriteLine("ya belhote");
                                        }
                                        break;

                                    case "sup": //Do that
                                        {
                                            Console.WriteLine("sup");
                                        }
                                        break;

                                    case "IDIOTA": //Do that
                                        {
                                            Console.WriteLine("IDIOTA ES TU");
                                        }
                                        break;

                                    case "idiota": //Do that
                                        {
                                            Console.WriteLine("IDIOTA ES TU");
                                        }
                                        break;

                                    case "ok": //Do that
                                        {
                                            Console.WriteLine("Ok!");
                                        }
                                        break;

                                    case "OK": //Do that
                                        {
                                            Console.WriteLine("Ok!");
                                        }
                                        break;

                                    case "sim esta tudo bem": //Do that
                                        {
                                            Console.WriteLine("Ainda bem,queres saber as novidades?");
                                        }
                                        break;

                                    case "SIM ESTA TUDO BEM": //Do that
                                        {
                                            Console.WriteLine("ACHO BEM!!!!");
                                        }
                                        break;

                                    case "Yep": //Do that
                                        {
                                            Console.WriteLine("Ainda bem,queres saber as novidades?");
                                        }
                                        break;

                                    case "La se vai": //Do that
                                        {
                                            Console.WriteLine("Acho bem que sim,há que continuar!");
                                        }
                                        break;

                                    case "Não": //Do that
                                        {
                                            Console.WriteLine("Não te preocupes,tudo irá melhorar");
                                        }
                                        break;

                                    case "NÃO": //Do that
                                        {
                                            Console.WriteLine("Não te preocupes,tudo irá melhorar");
                                        }
                                        break;

                                    case "nope": //Do that
                                        {
                                            Console.WriteLine("Não te preocupes,tudo irá melhorar");
                                        }
                                        break;

                                    case "não": //Do that
                                        {
                                            Console.WriteLine("Não te preocupes,tudo irá melhorar");
                                        }
                                        break;



                                    case "Novidades": //Do that
                                        {
                                            Console.WriteLine("Ouvi dizer que há um grupo do liceu fernão magalhães que está a tentar criar uma..inteligência artificial...que mestres!!! ");
                                        }
                                        break;

                                    case "NOVIDADES": //Do that
                                        {
                                            Console.WriteLine("Ouvi dizer que há um grupo do liceu fernão magalhães que está a tentar criar uma..inteligência artificial...que mestres!!! ");
                                        }
                                        break;

                                    case "novidades": //Do that
                                        {
                                            Console.WriteLine("Ouvi dizer que há um grupo do liceu fernão magalhães que está a tentar criar uma..inteligência artificial ...que mestres!!! ");
                                        }
                                        break;

                                    case "És mesmo uma inteligência artificial?": //Do that
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "és mesmo uma inteligência artificial?": //Do that
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "Es mesmo uma inteligencia artificial?":
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "es mesmo uma inteligencia artificial?":
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "És mesmo uma inteligência artificial": //Do that
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "és mesmo uma inteligência artificial": //Do that
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "Es mesmo uma inteligencia artificial":
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "es mesmo uma inteligencia artificial":
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "És uma AI?":
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "És uma AI":
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "és uma AI?":
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "és uma AI":
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "es uma AI?":
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "es uma AI":
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "Es uma AI?":
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "Es uma AI":
                                        {
                                            Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
                                        }
                                        break;

                                    case "O que és?":
                                        {
                                            Console.WriteLine("Antes de mais,não,não sou uma inteligência artificial,isto por que para ser uma AI-IA teria de ser capaz de opinar por mim próprio,ter a capacidade de fazer decisões,e livre-arbítrio,etc");
                                        }
                                        break;

                                    case "o que és?":
                                        {
                                            Console.WriteLine("Antes de mais,não,não sou uma inteligência artificial,isto por que para ser uma AI-IA teria de ser capaz de opinar por mim próprio,ter a capacidade de fazer decisões,e livre-arbítrio,etc");
                                        }
                                        break;

                                    case "O que es?":
                                        {
                                            Console.WriteLine("Antes de mais,não,não sou uma inteligência artificial,isto por que para ser uma AI-IA teria de ser capaz de opinar por mim próprio,ter a capacidade de fazer decisões,e livre-arbítrio,etc");
                                        }
                                        break;

                                    case "o que es?":
                                        {
                                            Console.WriteLine("Antes de mais,não,não sou uma inteligência artificial,isto por que para ser uma AI-IA teria de ser capaz de opinar por mim próprio,ter a capacidade de fazer decisões,e livre-arbítrio,etc");
                                        }
                                        break;


                                    case "O que és":
                                        {
                                            Console.WriteLine("Antes de mais,não,não sou uma inteligência artificial,isto por que para ser uma AI-IA teria de ser capaz de opinar por mim próprio,ter a capacidade de fazer decisões,e livre-arbítrio,etc");
                                        }
                                        break;

                                    case "o que és":
                                        {
                                            Console.WriteLine("Antes de mais,não,não sou uma inteligência artificial,isto por que para ser uma AI-IA teria de ser capaz de opinar por mim próprio,ter a capacidade de fazer decisões,e livre-arbítrio,etc");
                                        }
                                        break;

                                    case "O que es":
                                        {
                                            Console.WriteLine("Antes de mais,não,não sou uma inteligência artificial,isto por que para ser uma AI-IA teria de ser capaz de opinar por mim próprio,ter a capacidade de fazer decisões,e livre-arbítrio,etc");
                                        }
                                        break;

                                    case "o que es":
                                        {
                                            Console.WriteLine("Antes de mais,não,não sou uma inteligência artificial,isto por que para ser uma AI-IA teria de ser capaz de opinar por mim próprio,ter a capacidade de fazer decisões,e livre-arbítrio,etc");
                                        }
                                        break;

                                    case "Quem és?":
                                        {
                                            Console.WriteLine("Antes de mais,não,não sou uma inteligência artificial,isto por que para ser uma AI-IA teria de ser capaz de opinar por mim próprio,ter a capacidade de fazer decisões,e livre-arbítrio,etc");
                                        }
                                        break;

                                    case "quem és?":
                                        {
                                            Console.WriteLine("Antes de mais,não,não sou uma inteligência artificial,isto por que para ser uma AI-IA teria de ser capaz de opinar por mim próprio,ter a capacidade de fazer decisões,e livre-arbítrio,etc");
                                        }
                                        break;

                                    case "Quem és":
                                        {
                                            Console.WriteLine("Antes de mais,não,não sou uma inteligência artificial,isto por que para ser uma AI-IA teria de ser capaz de opinar por mim próprio,ter a capacidade de fazer decisões,e livre-arbítrio,etc");
                                        }
                                        break;

                                    case "quem és":
                                        {
                                            Console.WriteLine("Antes de mais,não,não sou uma inteligência artificial,isto por que para ser uma AI-IA teria de ser capaz de opinar por mim próprio,ter a capacidade de fazer decisões,e livre-arbítrio,etc");
                                        }
                                        break;

                                    case "Quem te fez?":
                                        {
                                            Console.WriteLine("Ezequiel Santos,um programador de c#!");
                                        }
                                        break;

                                    case "quem te fez?":
                                        {
                                            Console.WriteLine("Ezequiel Santos,um programador de c#!");
                                        }
                                        break;

                                    case "Quem te fez":
                                        {
                                            Console.WriteLine("Ezequiel Santos,um programador de c#!");
                                        }
                                        break;

                                    case "quem te fez":
                                        {
                                            Console.WriteLine("Ezequiel Santos,um programador de c#!");
                                        }
                                        break;

                                    case "calculator":
                                        {

                                            double result = 0;
                                            double firstNumber = SetNumber("Type you first number : ");
                                            double secondNumber = SetNumber("Type you second number: ");

                                            string stringOperation =
                                                SetOperation(
                                                    "Enter the operation + (addition), - (soustraction), * (multiplication), / (division), ^ (exposant) or % (reste) :");

                                            switch (stringOperation)
                                            {
                                                case "+":
                                                case "addition":
                                                    result = firstNumber + secondNumber;
                                                    break;
                                                case "-":
                                                case "soustraction":
                                                    result = firstNumber - secondNumber;
                                                    break;
                                                case "*":
                                                case "multiplication":
                                                    result = firstNumber * secondNumber;
                                                    break;
                                                case "/":
                                                case "division":
                                                    result = firstNumber / secondNumber;
                                                    break;
                                                case "^":
                                                case "exposant":
                                                    result = Math.Pow(firstNumber, secondNumber);
                                                    break;
                                                case "%":
                                                case "reste":
                                                    result = firstNumber % secondNumber;
                                                    break;
                                            }
                                            Console.WriteLine("Result of {0} {1} {2} = {3}", firstNumber, stringOperation, secondNumber, result);
                                            Console.ReadKey();




                                        }
                                        break;



                                }

                            } while (choice != "0");



                        }

                }






            }
            {

            }











        private static string choice;
        private static string mudar;



        private static readonly string[] operations = { "+", "-", "*", "/", "^", "%" };

        private static double SetNumber(string outputText)
        {
            double parse;
            Console.Write(outputText);
            string tempInput = Console.ReadLine();
            while (!double.TryParse(tempInput, out parse))
            {
                Console.WriteLine("Incorrect input !");
                Console.Write(outputText);
                tempInput = Console.ReadLine();
            }
            return double.Parse(tempInput);
        }

        private static bool IsValidOperation(string input)
        {
            return operations.Contains(input);
        }

        private static string SetOperation(string outputText)
        {
            Console.Write(outputText);
            string tempInput = Console.ReadLine();
            while (!IsValidOperation(tempInput))
            {
                Console.WriteLine("Incorrect input !");
                Console.Write(outputText);
                tempInput = Console.ReadLine();
            }
            return tempInput;
        }






    }
        
            





}


What I have tried:

everything what intelli sense said,but i can't figured it out,im just a newbie
Before someone asks why is it that weird,it is just for a class work xD
Posted
Updated 11-Jun-18 20:18pm
Comments
phil.o 11-Jun-18 22:38pm    
"why is it that weird" is not the first question which comes to mind.
You just have posted a block of code, asking for help to something we do not know anything about.
Please use the green "Improve question" button, and add some informations to your post:
- what is the problem? does this compile? is there an error message, or a specific exception thrown? if not, what is it with the result you get wich differs from what you are expecting?
Remember that we do not know anything about your problem, so you may have to describe it if you want to get meaningful answers.
Edit: as a side-note, your configured user name may be off the charts for these forums.
Jinto Jacob 12-Jun-18 0:02am    
what is your error. Please provide the error you are getting
F-ES Sitecore 12-Jun-18 4:40am    
So you wrote 100 lines of code without ever running it or testing it, or even compiling it?

Start by looking at the "Error List" pane - it you don't have it open then you should! Press CTRL+W then E and it'll appear.
Each compilation error has a number, a message, a file, a Line number, a column number, and a project:
Error	1	} expected	D:\Documents\AA Backed Up\My Projects\GeneralTesting\GeneralTestingConsole\Program.cs	490	14	GeneralTestingConsole
And if you double click on the error it will take you direct to the line it doesn't like.
In this case this is from your code, and it's the first error message - it's expecting a "}" rather than an "{". Why? Because you have got bits missing here - you have two "do" loops, but only one "while" to end them, and so on.
I'd strongly suggest that you make a copy of that code (so you can go back to it if you mess it up completely) and refactor it to use more methods.
Take your outer switch and make each case a separate method: That'll be pretty simpel at the moment, because there is only one case in it!
switch (choice)
{
    case "iniciar":
        {
        UserIniciar();
        break;
        }
...
}
Then it's obvious that you missed out the break at the end of the case, and the structure of your main method becomes clearer. Repeat this for your inner casees and your code should start to become more manageable and easier to correct!
 
Share this answer
 
Comments
[no name] 12-Jun-18 2:21am    
Good point about making separate methods.
The main problem is that it doesn't compile. This has two reasons:

1. The curly braces don't match up.
2. The first do has no matching while.

After fixing that, as far as I can tell, without being able to read Portuguese, it's a functional command interpreter.

Another problem however is that your code is going to be very hard to maintain with all the duplication. Instead of handling all the command variations with capitals, I would convert the input to lower case and check for that. For cases with accents, you don't need to duplicate the flow. For example:

switch (Console.ReadLine().ToLower()) {
	case "és mesmo uma inteligência artificial?":
	case "es mesmo uma inteligencia artificial?":
		Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
		break;

	case "és uma ai?":
	case "es uma ai?":
		Console.WriteLine("Não,não sou,isto por que,uma inteligência artificial seria capaz de opinar por si própria,ter uma opinião e ter a capacidade de fazer decisões,etc");
		break;
}
 
Share this answer
 
v2
Comments
Eric Lynch 12-Jun-18 6:06am    
I was just going to suggest Thaddeus Jones' improvement. Additionally, if you want ignore diacritics (as well as case), you may want to check out the following:

https://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net

It's not perfect, but should cover most cases for the Portuguese language.

Surprised you don't have the "Would you like to play a game?" meme from War Games included in your choices :) Good luck.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900