Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Examen Final Programacion Orientada A Objetos
Examen Final Programacion Orientada A Objetos
PROBLEMA 1
// problema 1 final.cpp : Defines the entry point for the console application.
//
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<time.h>
using namespace std;
class recta {
protected:
int x1, y1, x2, y2;
public:
recta();
recta(float, float, float, float);
void mostrar();
void pendiente();
float distancia();
};
recta::recta() {
x1 = rand()%10+1; y1 = rand() % 10 + 1;
x2 = rand() % 10 + 1; y2= rand() % 10 + 1;
}
recta::recta(float a, float b, float c, float d) {
x1 = a; y1 = b;
x2 = c; y2 = d;
}
void recta::pendiente() {
if ((x2 - x1)! = 0) {
float m;
m = float(y2 - y1) / (x2 - x1);
cout << "La pendiente de la recta es: " << m << endl;
cout << "La eucacion de la recta es: " << "mX+b=Y" << endl;
cout << "m= " << m << endl;
cout << "b= " << y1 - x1 * m << endl;
}
else
cout << "Es una recta vertical " << endl;
}
float recta::distancia() {
float d;
d= sqrtf(powf((x1 - x2), 2) + powf((y1 - y2), 2));
return(d);
}
void recta::mostrar() {
cout << "La primera coordenada es: " << "( " << x1 << " ; " << y1 << " )" << endl;
cout << "La segunda coordenada es: " << "( " << x2 << " ; " << y2 << " )" << endl;
}
RGB(255,0,0), RGB(0,255,0),
RGB(0,0,255), RGB(255,255,0),
RGB(255,0,255), RGB(0,255,255),
RGB(127,127,127), RGB(255,255,255)};
CPen n_pincel;
CPen *v_pincel;
CRect rect;
GetClientRect(rect);
int cy=(rect.bottom-rect.top);
dc.SetMapMode(MM_ANISOTROPIC);
dc.SetWindowExt(840,300);
dc.SetViewportOrg(cx,-cy);
dc.SetViewportExt(cx,-cy);
dc.SetViewportOrg(cx/2,cy/2);
double x,y,u;
for(int u=0;u<361;u++){
x=50*((u*3.141516/180)-sin(u*3.1416/180));
y=50*(1-cos(u*3.1416/180));
dc.SetPixel(x,y,RGB(0,0,255));}
dc.TextOut(120,40,_T("cicloide"));
n_pincel.CreatePen(PS_SOLID, 1,dwColor[0]);
v_pincel=dc.SelectObject(&n_pincel);
dc.MoveTo(0,-140);
dc.LineTo(0,140);
dc.TextOut(0,145,_T("Y"),1);
dc.SelectObject(v_pincel);
n_pincel.DeleteObject();
n_pincel.CreatePen(PS_SOLID, 1,dwColor[0]);
v_pincel=dc.SelectObject(&n_pincel);
dc.MoveTo(-100,0);
dc.LineTo(300,0);
dc.TextOut(305,0,_T("X"),1);
dc.SelectObject(v_pincel);
n_pincel.DeleteObject();
dc.Ellipse(0,10,280,300);
dc.Ellipse(0,20,260,290);
dc.Ellipse(0,30,240,280);
dc.Ellipse(0,40,220,270);
dc.Ellipse(0,50,200,260);
dc.Ellipse(0,60,180,250);
dc.Ellipse(0,70,160,240);
dc.Ellipse(0,80,140,220);
dc.Ellipse(0,90,120,210);
dc.Ellipse(0,100,100,200);
PROBLEMA 4
#include "stdafx.h"
#include "Problema4.h"
#include "Problema4Dlg.h"
#include "afxdialogex.h"
#include "Cconfigu.h"
#include "Cvalencia.h"
#include "Ccuantico.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD)
{
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
// CProblema4Dlg dialog
BEGIN_MESSAGE_MAP(CProblema4Dlg, CDialogEx)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_Salir, &CProblema4Dlg::OnBnClickedSalir)
ON_BN_CLICKED(IDC_RADIO_VerConfigu,
&CProblema4Dlg::OnBnClickedRadioVerconfigu)
ON_BN_CLICKED(IDC_RADIO_VerElectro,
&CProblema4Dlg::OnBnClickedRadioVerelectro)
ON_BN_CLICKED(IDC_RADIO_VerNumeroCuan,
&CProblema4Dlg::OnBnClickedRadioVernumerocuan)
END_MESSAGE_MAP()
BOOL CProblema4Dlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
return TRUE; // return TRUE unless you set the focus to a control
}
void CProblema4Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND,
reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// The system calls this function to obtain the cursor to display while the user
drags
// the minimized window.
HCURSOR CProblema4Dlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CProblema4Dlg::OnBnClickedSalir()
{
// TODO: Add your control notification handler code here
PostQuitMessage(0);
}
void CProblema4Dlg::OnBnClickedRadioVerconfigu()
{
// TODO: Add your control notification handler code here
Cconfigu sistema;
sistema.Configuracion = "1s2 2s2 2p6 3s2 3p6 3d10 4s2 4p5";
UpdateData(false);
sistema.DoModal();
void CProblema4Dlg::OnBnClickedRadioVerelectro()
{
// TODO: Add your control notification handler code here
Cvalencia sistema;
sistema.Electrones= 7;
UpdateData(false);
sistema.DoModal();
}
void CProblema4Dlg::OnBnClickedRadioVernumerocuan()
{
// TODO: Add your control notification handler code here
Ccuantico sistema;
sistema.cuantico=4;
UpdateData(false);
sistema.DoModal();
}
}
}
}