VinBR

ES - TP1 - Interface das Classes do Jogo

Oct 22nd, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.20 KB | None | 0 0
  1. /*
  2.  *  Lembrete de debate:
  3.  *  Discutir os get's e set's
  4.  *  
  5.  *  Discutir se a qualidade vai afetar o bonus de um projeto.
  6.  *
  7.  *  Discutir a controladora, tem muita coisa lá para decidirmos.
  8.  *
  9.  *  Discutir se é necessário guardar o turno de termino de uma tarefa.
  10.  *  
  11.  *  Pedir para lerem os comentário no final do arquivo.
  12.  *
  13.  */
  14.  
  15. using System.Collections.Generic;
  16.  
  17. namespace Controle
  18. {
  19.     public class cTarefa
  20.     {
  21.         public String nome { get; set; }
  22.         public int ID { get; set; }
  23.         public Ambiente.eCategoria tipo { get; set; }
  24.  
  25.         // A qualidade acumulada da Tarefa é o bonus de qualidade que veio de outras tarefas.
  26.         // Deve ser inicializada com o valor 0.
  27.         public int Qualidade_acumulada { get; set; }
  28.  
  29.         // Indica se a tarefa já foi completada.
  30.         // Deve ser iniciada como false.
  31.         public bool completada { get; private set; }
  32.  
  33.         // Guarda o turno em que a tarefa foi completada;
  34.         // Não precisa ser inicializada.
  35.         // Quando ele receber uma chamada ao `set` a variável `completada` será marcada como `true`.
  36.         public int data_do_termino {
  37.  
  38.             get{return this.data_do_termino;}
  39.  
  40.             private set { completada = true; data_do_termino = value; }
  41.  
  42.         }
  43.         // <Nota Garcia> Essa variavel foi requisitada pelo jesus, eu acho que ela pode ser desnecessária. </Nota>
  44.  
  45.         // Completa a tarefa e seta a `data` para a variável `data_do_termino`
  46.         public void completa_tarefa(int data) { throw new NotImplementedException(); }
  47.  
  48.         // Construtora, inicia as demais variáveis.
  49.         public cTarefa(int nome, int ID, Ambiente.eCategoria tipo_da_tarefa) { throw new NotImplementedException(); }
  50.     }
  51. }
  52.  
  53.  
  54.    /*
  55.      * Comentário Garcia:
  56.      * Pode ser interessante criar uma função serialize e deserialize
  57.      * para podermos guardar os dados de cada projeto nosso em um arquivo.txt
  58.      *
  59.      * Caso agente não faça isso, vamos ter de inicializar cada variável da classe cProjeto
  60.      * e como vão ser uns 10 projetos isso vai poluir muito o código.
  61.      */
  62.     public class cProjeto
  63.     {
  64.         // Um struct que guarda os efeitos positivos ou negativos de completar ou falhar na missão:
  65.         public struct tBuff
  66.         {
  67.             public int repModif;
  68.             public int dinheiroModif;
  69.         }
  70.    
  71.         // As variáveis abaixo contém o buff e o debuf do projeto.
  72.         // Devem ser inicializadas na construtora.
  73.         public tBuff bonus { get; set; }
  74.         public tBuff penalidade { get; set; }
  75.    
  76.         // A qualidade acumulada do Projeto é qualidade gerada pelas tarefas
  77.         // que geram bonus diretamente para o projeto.
  78.         // Deve ser inicializada como 0.
  79.         public int qualidade_acumulada { get; set; }
  80.    
  81.         // Indica o turno limite até onde o projeto pode ser completado.
  82.         public int prazo_do_projeto {get; set;}
  83.    
  84.         // A lista abaixo deve conter um subconjunto das tarefas pré-fabricadas
  85.         // encontradas em ambiente.getTarefa(int ID).
  86.         public cTarefa[] tarefa;
  87.         public cTarefa getTarefa(int ID) { throw new NotImplementedException(); }
  88.         public void setTarefa(cTarefa tarefa, int ID) { throw new NotImplementedException(); }
  89.    
  90.         public enum eCompletado { NaoCompletado, CompletadoSucesso, CompletadoFalhou }
  91.         // Inicializado como NaoCompletado:
  92.         public eCompletado completado {get; set;}
  93.    
  94.         // Inicializa as demais variáveis.
  95.         public cProjeto(tBuff bonus, tBuff penalidade, cTarefa[] tarefas) { throw new NotImplementedException(); }
  96.         public cProjeto() { throw new NotImplementedException(); }
  97.     }
  98.  
  99.  
  100.     public class cFuncionario
  101.     {
  102.         //<Nota Garcia> Posso ter esquecido algum dado do funcionário </nota>    
  103.  
  104.         public String nome {get; set;}
  105.         public Ambiente.eCategoria cargo {get; set;}
  106.         public String descricao {get; set;}
  107.    
  108.         public int salario {get; set;}
  109.    
  110.         // Guarda a tarefa a ser realizada no próximo turno.
  111.         // Inicializada como vazia.
  112.         cTarefa tarefa_do_turno {get; set;}
  113.    
  114.         // Guarda o projeto onde a tarefa acima será realizada.
  115.         // Inicializado como vazio.
  116.         cProjeto projeto_atual {get; set;}
  117.     }
  118.  
  119.     static class Financeiro
  120.     {
  121.         public struct tTransacao
  122.         {
  123.             String motivo;
  124.             int valor;
  125.             int data_da_ocorrencia;
  126.         }
  127.  
  128.         public static List<tTransacao> transacao {
  129.             get { return Financeiro.transacao; }
  130.         }
  131.         public static void setTransacao(tTransacao transacao) { throw new NotImplementedException(); }
  132.     }
  133.  
  134.     static class Jogador
  135.     {
  136.         public static String nome { get; set; }
  137.         public static String nome_empresa { get; set; }
  138.  
  139.         // O array de investidores tem 3 posições.
  140.         // Cada posição é true se o investidor tiver sido escolhido e false caso contrário.
  141.         public static bool[] investidores { get; set; }
  142.  
  143.         // Os valores iniciais das variáveis abaixo devem ser decididos posteriormente.
  144.         public static int dinheiro { get; set; }
  145.         public static int reputacao { get; set; }
  146.  
  147.         // O array de projetos ativos tem tamanho 3.
  148.         // Eles devem ser inicializados como `null`
  149.         private static cProjeto[] projetos_ativos;
  150.         public static cProjeto getProjeto(int i) { throw new NotImplementedException(); }
  151.         public static void setProjeto(cProjeto projeto, int i) { throw new NotImplementedException(); }
  152.  
  153.         // O array de funcionarios ativos tem tamanho 6.
  154.         // Eles devem ser inicializados como `null`
  155.         private static cFuncionario[] funcionarios;
  156.         public static cFuncionario getFuncionario(int i) { throw new NotImplementedException(); }
  157.         public static void setFuncionario(cFuncionario funcionario, int i) { throw new NotImplementedException(); }
  158.  
  159.         // O get e set abaixo recebem `i` que é um indice com base na posição
  160.         // do projeto no array `projetos_ativos` e não no ID do projeto!
  161.         public static cProjeto getProjeto_ativo(int i) { throw new NotImplementedException(); }
  162.         public static void setProjeto_ativo(cProjeto projeto, int i) { throw new NotImplementedException(); }
  163.  
  164.     }
  165.  
  166.     static class Controle
  167.     {
  168.         /* Chama a função tarefa.completa_tarefa(int data)
  169.          * Atualiza a qualidade_acumulada do projeto, e a qualidade_acumulada
  170.          * das outras tarefas do projeto com base nas tabelas:
  171.          * `ambiente.mTarefaTarefa` e `ambiente.mTarefaItem`
  172.          * Também leva em consideração os bonus do Funcionário.
  173.          *
  174.          * Retorna erro se:
  175.          * O funcionário não tiver o cargo necessário para realizar a tarefa
  176.          * (verifique isso na tabela `ambiente.mCargoTarefa`, ou se
  177.          * Algum pre-requisito da tarefa não tiver sido completado.
  178.          * Verifique isso na tabela: `ambiente.mTarefaTarefa`
  179.          *
  180.          * A função também deve verificar se o projeto está completo.
  181.          * Caso afirmativo deve marca-lo como completo e providenciar os bonus ao jogador na classe `jogador`
  182.          */
  183.         public static void completar_tarefa(cTarefa tarefa, cProjeto projeto, cFuncionario funcionario)
  184.         {
  185.             throw new NotImplementedException();
  186.         }
  187.  
  188.         /*
  189.          * Escolhe dentre os projetos definidos em `ambiente.getProjeto(i)`
  190.          * deve escolher um de forma aleatória.
  191.          *
  192.          * Algumas restrições precisam ser evitadas, envolvendo a reputação e os investidores.
  193.          * <Nota Garcia> Temos de discutir que restrições são essas. Ainda não sabemos. </Nota>
  194.          */
  195.         public static cProjeto sorteia_projeto(int reputacao, bool[] investidores)
  196.         {
  197.             throw new NotImplementedException();
  198.         }
  199.  
  200.         /*
  201.          * Gera um funcionários escolhidos de forma aleatória
  202.          * dentre os funcionários disponíveis em `ambiente.getFuncionario(i)`
  203.          *
  204.          */
  205.         public static cFuncionario processo_seletivo()
  206.         {
  207.             throw new NotImplementedException();
  208.         }
  209.  
  210.         // Os logs abaixo devem ser auto-explicativos.
  211.         // Precisam imprimir uma linha explicando o acontecimento no arquivo "log.txt" <sujeito a debate>
  212.         public static void Log_realizou_tarefa(cTarefa tarefa, int data) { throw new NotImplementedException(); }
  213.         public static void Log_contratou_funcionario(cFuncionario funcionario, int data) { throw new NotImplementedException(); }
  214.         public static void Log_demitiu_funcionario(cFuncionario funcionario, int data) { throw new NotImplementedException(); }
  215.         public static void Log_aceitou_projeto(cProjeto projeto, int data) { throw new NotImplementedException(); }
  216.         public static void Log_completou_projeto(cProjeto projeto, int data) { throw new NotImplementedException(); } // (falhou ou não, mas completou)
  217.         public static void Log_encerrou_turno(int data) { throw new NotImplementedException(); }
  218.         public static void Log_terminou_jogo(int data) { throw new NotImplementedException(); } // (venceu ou perdeu)
  219.  
  220.     }
  221.  
  222.     public static class Ambiente
  223.     {
  224.         // Guarda o turno atual do jogo.
  225.         public static int date {get; set;}
  226.  
  227.         // A enumeracao abaixo contém os nomes que diferenciam as areas de atuação na engenharia de software.
  228.         // A enumeracao está incompleta, porque só lembrei de 3 nomes, é preciso preencher o resto.
  229.         public enum eCategoria { Requisitos, Analise, Desenho, Implementacao, Teste, Gestão };
  230.  
  231.         // As matrizes abaixo já estão inicializadas, editem os valores para a matriz correta.
  232.         // Quem for editar pode apagar a inicialização e fazer de forma manual dentro da construtora se preferir.
  233.         public static List<List<int>> mTarefaTarefa;
  234.         public static List<List<int>> mCargoTarefa;
  235.         public static List<List<int>> mTarefaItem;
  236.  
  237.         public static void preencheMatrizTarefaTarefa(string caminhoArquivo)
  238.         {
  239.             try
  240.             {
  241.                 mTarefaTarefa = new List<List<int>>();
  242.                 int indice = 0;
  243.  
  244.                 using (StreamReader sr = new StreamReader(caminhoArquivo))
  245.                 {
  246.                     string line = sr.ReadLine();
  247.                     string[] split = line.Split(new Char[] { ' ' });
  248.  
  249.                     // Cria uma nova lista de tarefa
  250.                     mTarefaTarefa[indice] = new List<int>();
  251.  
  252.                     int auxIndice = 0;
  253.  
  254.                     for (int i = 0; i < split.Count(); i++)
  255.                     {
  256.                         mTarefaTarefa[indice][i] = Convert.ToInt32(split[auxIndice]);
  257.                     }
  258.  
  259.                     indice++;
  260.                 }
  261.             }
  262.             catch (DirectoryNotFoundException ex)
  263.             {
  264.                 Console.WriteLine("Arquivo não encontrado em : " + caminhoArquivo);
  265.             }
  266.         }
  267.  
  268.         // Retorna a posição (i,j) da matriz mTarefaTarefa
  269.         public static int getTarefaTarefa(int i, int j){
  270.             throw new NotImplementedException();
  271.         }
  272.    
  273.         // Retorna a posição (i,j) da matriz mCargoTarefa
  274.         public static int getCargoTarefa(int i, int j){
  275.             throw new NotImplementedException();
  276.         }
  277.    
  278.         // Retorna a posição (i,j) da matriz mTarefaItem
  279.         public static int getTarefaItem(int i, int j){
  280.             throw new NotImplementedException();
  281.         }
  282.    
  283.         // Esse array precisa ser inicializado na construtora.
  284.         // Segundo a descrição do jesus ele conterá os projetos que criamos manualmente.
  285.         // Note que o indice do projeto nesse array e o ID do projeto são identicos nesse array.
  286.         private static readonly cProjeto[] projeto;
  287.         public static cProjeto getProjeto(int i){
  288.             throw new NotImplementedException();
  289.         }
  290.  
  291.         // Esse array precisa ser inicializado na construtora.
  292.         // Segundo a descrição do jesus ele conterá os funcionarios que criamos manualmente.
  293.         // Note que o indice do funcionario nesse array e o ID do funcionario são identicos nesse array.
  294.         public static cFuncionario[] funcionario;
  295.         public static cFuncionario getFuncionario(int i){
  296.             throw new NotImplementedException();
  297.         }
  298.         // Esse array precisa ser inicializado na construtora.
  299.         // Esse array conterá as tarefas que especificamos previamente, com nome, categoria e indice.
  300.         // Note que o indice da tarefa nesse array e o ID da tarefa são identicos nesse array.
  301.         private static readonly cTarefa[] tarefa;
  302.         public static cTarefa getTarefa(int i){
  303.             throw new NotImplementedException();
  304.         }
  305.    
  306.         // O dicionário abaixo precisa ser preenchido com os pares:
  307.         // <nome do funcionário>, <indice do funcionário no array "this.funcionario">
  308.         // O preenchimento deve ocorrer dentro da construtora.
  309.         private static readonly Dictionary<String, int> nomesFuncionarios = new Dictionary<String, int>();
  310.         public static int getIDFuncionario(String nome){
  311.             throw new NotImplementedException();
  312.         }
  313.        
  314.         // Inicializa a matriz mTarefaTarefa com os valores corretos.
  315.  
  316.  
  317.     }
  318.  
  319. /*
  320.  *  Exemplo de uso de um dicionario:
  321.  *
  322.  *  // Biblioteca necessária para usar o Dictionary:
  323.  *  using System.Collections.Generic;
  324.  *
  325.  *  Dictionary<string, int> dictionary = new Dictionary<string, int>();
  326.  *  dictionary.Add("cat"   ,  2);
  327.  *  dictionary.Add("dog"   ,  1);
  328.  *  dictionary.Add("llama" ,  0);
  329.  *  dictionary.Add("iguana", -1);
  330.  *
  331.  *  // Para acessar o terceiro valor digito:
  332.  *  ID_llama = dictionary["llama"];
  333.  */
  334.  
  335. /*
  336.  * Inicializando uma Classe junto com suas variáveis com os get's e set's colocados corretamente:
  337.  *
  338.  * class Thing {
  339.  *     public string Prop1 {get; set; }
  340.  *     public string Prop2 {get; set; }
  341.  *     public string Prop3 {get; set; }
  342.  *     public int    Prop4 {get; set; }
  343.  * }
  344.  *
  345.  * Thing t = new Thing() { Prop1 = "expensive", Prop2 = "costly", Prop3 = "pricy", Prop4 = 0};
  346.  *
  347.  */
Advertisement
Add Comment
Please, Sign In to add comment