Solução do Exercício Cadastro Alunos: mudanças entre as edições

De IFSC
Ir para navegação Ir para pesquisar
imported>Fargoud
Sem resumo de edição
imported>Fargoud
Sem resumo de edição
Linha 100: Linha 100:
   ...
   ...
   ...
   ...
}
  }
  #pragma endregion
  #pragma endregion
   private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
   private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
Linha 140: Linha 140:
       listBox1->SelectedIndex = 0;  
       listBox1->SelectedIndex = 0;  
   }
   }
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
       int i;
       int i;
       paluno.NomeAluno = textBox1->Text;
       paluno.NomeAluno = textBox1->Text;

Edição das 15h38min de 28 de março de 2018

Tela Design criada para Form1:

Form1dsg.png

Tela em tempo de execução:

Form1rt.png



Código classe Aluno.h:

#pragma once
using namespace System; //para poder usar classe String^
ref class Aluno
{
public:
   Aluno(void);
   String^ NomeAluno;
   String^ NumMatricula;
   String^ ListaDisciplinas;
   void ImprimeSaida();
   void EntraNotas();
   int ndisc;	
   bool aprovado;	
   float Medias;
private:
   void Calcula_Medias();
};


Código classe Aluno.cpp:

   #include "StdAfx.h"
   #include "Aluno.h"
   Aluno::Aluno(void)
   {
     aprovado = true;
   }
   void Aluno::ImprimeSaida()
   {int i;
   for(i=0;i<ndisc;i++)
      if(Medias < 6)
         aprovado = false;
   }
 void Aluno::Calcula_Medias()
 {
 }
 void Aluno::EntraNotas()
 {
 }


Código Form1.h

#include "CadastraNomes.h"
#include "Aluno.h"  
using namespace std;
#pragma once
namespace RegistroAcademico {
  using namespace System;
  using namespace System::ComponentModel;
  using namespace System::Collections;
  using namespace System::Windows::Forms;
  using namespace System::Data;
  using namespace System::Drawing;
  /// <summary>
  /// Summary for Form1
  ///
  /// WARNING: If you change the name of this class, you will need to change the
  ///          'Resource File Name' property for the managed resource compiler tool
  ///          associated with all .resx files this class depends on.  Otherwise,
  ///          the designers will not be able to interact properly with localized
  ///          resources associated with this form.
  /// </summary>
  public ref class Form1 : public System::Windows::Forms::Form
  {   Aluno paluno; //**declaração do objeto aqui - global ao Form!!!!
  public:
  Form1(void)
  {
  InitializeComponent();
  //
  //TODO: Add the constructor code here
  //		
  }
  protected:
  // <summary>
  /// Clean up any resources being used.
  /// </summary>
  ~Form1()
  {
     if (components)
     {
        delete components;
     }
  }
  private: System::Windows::Forms::Button^  button1;
 ...
 ...
 ...
 }
#pragma endregion
  private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
 static float soma=0;
  int n;
  if(listBox2->Items->Count < 5)
     { label3->Enabled = true;
       label5->Enabled = true;
       label6->Enabled = true;
       label7->Enabled = true;
       listBox2->Items->Add(maskedTextBox2->Text);
       soma += Convert::ToDouble(maskedTextBox2->Text);
       n = Convert::ToInt16(listBox2->Items->Count);
       listBox2->Select();
       maskedTextBox2->Clear();
       maskedTextBox2->Focus(); 
     }
     else
     {	 MessageBox::Show("Limite máximo de notas por disciplina: 5",
   "Número Máximo de Notas", 
    MessageBoxButtons::OK, MessageBoxIcon::Error);
     maskedTextBox2->Clear();
     }
     paluno.Medias = soma/n;
     label6->Text = Convert::ToString(paluno.Medias);
  }
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
      if(listBox1->Items->Count < 10)
     { listBox1->Items->Add(textBox2->Text);
       listBox1->Select();
       textBox2->Clear();
       textBox2->Focus(); }
     else
     {	 MessageBox::Show("Limite máximo de disciplinas por semestre: 10",
       "Número Máximo de Disciplinas", 
        MessageBoxButtons::OK, MessageBoxIcon::Error);
        textBox2->Clear();
      }
     listBox1->SelectedIndex = 0;	 
 }
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
     int i;
     paluno.NomeAluno = textBox1->Text;
     paluno.NumMatricula = maskedTextBox1->Text;
     paluno.ListaDisciplinas = listBox1->Items->ToString();
     paluno.ndisc = listBox1->Items->Count;
     if(paluno.Medias >=6)
     {	paluno.aprovado = true;
        label7->Text = "Apto";
     }
     else
     {	paluno.aprovado = false;
       label7->Text = "Não Apto";
     }
   }

}; }