Exemplo n.º 1
0
        public bool criarNovoPrograma()
        {
            Console.WriteLine("Escreva o alimento que o programa irá esquentar");
            String nome = Console.ReadLine().Trim();

            Console.WriteLine("Escreva a potencia com um numero de {0} a {1}", Constants.minPowerPossible, Constants.maxPowerPossible);
            String potenciaString = Console.ReadLine();
            int    potencia;

            if (!Int32.TryParse(potenciaString, out potencia))
            {
                potencia = -1;
            }

            Console.WriteLine("Escreva o tempo com um numero de {0} a {1}", Constants.minTimePossible, Constants.maxTimePossible);
            String tempoString = Console.ReadLine();
            int    tempo;

            if (!Int32.TryParse(tempoString, out tempo))
            {
                tempo = -1;
            }

            Console.WriteLine("Escreva o caractere de aquecimento que o programa irá esquentar");
            char caracter = Console.ReadLine().ToCharArray()[0];

            Console.WriteLine("Escreva o alimento que o programa irá esquentar");
            String instrucao = Console.ReadLine();

            ResponseSchema response = programsController.criarPrograma(nome, potencia, tempo, caracter, instrucao);

            Console.WriteLine(response.getMessage());

            return(response.getError());
        }
Exemplo n.º 2
0
        public ResponseSchema definePrograma(ProgramsSchema programa)
        {
            ResponseSchema resNome     = model.setAlimento(programa.getName());
            ResponseSchema resChar     = model.setCaractere(programa.getCharacter());
            ResponseSchema resTempo    = model.setTempo(programa.getTime());
            ResponseSchema resPotencia = model.setPotencia(programa.getPower());


            if (resNome.getError())
            {
                return(resNome);
            }

            if (resChar.getError())
            {
                return(resChar);
            }

            if (resPotencia.getError())
            {
                return(resPotencia);
            }

            if (resTempo.getError())
            {
                return(resTempo);
            }

            return(new ResponseSchema(false, Constants.messageSuccessSetProgram));
        }
Exemplo n.º 3
0
        public bool aquecer()
        {
            ResponseSchema response = microWaveController.aquecer();

            Console.WriteLine(response.getMessage());

            return(response.getError());
        }
Exemplo n.º 4
0
        private bool defineTempo(int valor)
        {
            ResponseSchema response = microWaveController.defineTempo(valor);

            Console.WriteLine(response.getMessage());

            return(response.getError());
        }
Exemplo n.º 5
0
        protected void UpdateResponse(ResponseSchema dataResponse)
        {
            try {
                // Create an instance of our AppDelegate
                AppDelegate appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate;

                // Update Data
                appDelegate.Storage = api.toString(dataResponse);
            } catch (Exception ex) {
                // Console
                Console.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 6
0
        protected void UpdateResponse(ResponseSchema dataResponse)
        {
            try {
                // Updated Session
                ISharedPreferencesEditor session_editor = session.Edit();

                // Update Data
                session_editor.PutString("storage", api.toString(dataResponse));
                session_editor.Commit();
            } catch (Exception ex) {
                // Console
                Console.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 7
0
        public string GetResponseSchemaName()
        {
            switch (ResponseSchema)
            {
            case null:
                return("@undefined");

            case JValue value:
                return($"@{((string)value).ToLowerInvariant()}");

            case JObject schema:
                return((string)schema["title"]);

            default:
                throw new ApplicationException($"unexpected ResponseSchema type: {ResponseSchema.GetType()}");
            }
        }
        public string GetResponseSchemaName()
        {
            switch (ResponseSchema)
            {
            case null:
                return("@undefined");

            case string value:
                return($"@{value.ToLowerInvariant()}");

            case Dictionary <string, object?> schema:
                return((string?)schema["title"] ?? throw new NotSupportedException($"invalid ResponseSchema: {schema["title"]}"));

            default:
                throw new ApplicationException($"unexpected ResponseSchema type: {ResponseSchema.GetType()}");
            }
        }
Exemplo n.º 9
0
        public bool defineAlimento(String valor)
        {
            ProgramsSchema programa = programsController.buscarPrograma(valor);

            if (programa.getName() != "default")
            {
                ResponseSchema response = microWaveController.definePrograma(programa);

                Console.WriteLine(response.getMessage());

                return(response.getError());
            }

            Console.WriteLine(Constants.messageErrorGetProgram);
            Console.WriteLine("");
            Console.WriteLine(programsController.buscarNomeProgramas());
            Console.WriteLine("");
            return(true);
        }