Professional Documents
Culture Documents
Escuela Politecnica Nacional Operaciones Con Polinomios Ronny Rodriguez 2015-A
Escuela Politecnica Nacional Operaciones Con Polinomios Ronny Rodriguez 2015-A
Escuela Politecnica Nacional Operaciones Con Polinomios Ronny Rodriguez 2015-A
POLITECNICA
NACIONAL
OPERACIONES
CON POLINOMIOS
RONNY
RODRIGUEZ
2015-A
18/06/2015
INTERFAZ GRAFICA
CLS POLINOMIO
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package prypolinomios;
/**
*
* @author usuario
*/
public class ClsPolinomio {
private int _grado;
private float [] _a;
//Constructores
public ClsPolinomio (){
_grado=0;
}
public ClsPolinomio (int grd){
_grado=grd;
_a=new float [grd+1];
}
public ClsPolinomio(int grd,float []coef){
_grado=grd;
_a=coef;
}
public ClsPolinomio(ClsPolinomio x){
this._grado=x._grado;
this._a=x._a;
}
//Get and set
public float a (int indice){ // Get individual
return _a[indice];
}
public void a (int indice, float valor){
//Set individual
_a[indice]=valor;
}
public float [] a(){ //Get de toda la estructura
return _a;
}
public void a(float [] val){ //Set de toda la estructura
_a=val;
}
//Rutinas
public int numterm (){ //funcion q cacula el numero de terminos
return _grado+1;
}
public double Fx (float valx){
double FdeX=0;
for (int i=0; i<=_grado;i++)
FdeX=FdeX+_a[i]*Math.pow(valx,i);
return FdeX;
}
public ClsPolinomio mas (ClsPolinomio b){
ClsPolinomio resp; //declarar un polinomio resp pero no lo creamos
if(this._grado>b._grado){
resp=new ClsPolinomio(this);
for (int i=0; i<=b._grado; i++)
resp._a[i]=resp._a[i]+b._a[i];
}
else {
}
}
return p;
}
public String por (){//inicializamos t poniendo " "
String t=" ";
for (int i=0;i<=this._grado;i++){
t= t + " ( "+_a[this._grado -i]+ "X^" + (this._grado-i) + " ) +";
}
return t;
}
public String ver(){
String linea;
linea="";
for(int i=_grado; i>0 ;i--){
linea = linea + " " + _a[i] + "X^" + i + " + ";}
linea = linea + " " + _a[0] ;
return linea;
}
}
PRY POLINOMIO
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package prypolinomios;
/**
*
* @author usuario
*/
public class PryPolinomios {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code
(optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default
look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(WinPolinomio.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(WinPolinomio.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(WinPolinomio.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(WinPolinomio.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
}
//</editor-fold>
/*
* WinPolinomio.java
*
* Created on 05/06/2015, 08:40:26 AM
*/
package prypolinomios;
/**
*
* @author usuario
*/
public class WinPolinomio extends javax.swing.JFrame {
int n;
}
}
/**
java.util.logging.Logger.getLogger(WinPolinomio.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(WinPolinomio.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {