Baixe o app para aproveitar ainda mais
Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original
calculadora/nbproject/private/private.xml file:/C:/Users/Bernardo/Documents/NetBeansProjects/Calculadora/src/calculadora/Main.java file:/C:/Users/Bernardo/Documents/NetBeansProjects/Calculadora/src/Core/CalculadoraCore.java file:/C:/Users/Bernardo/Documents/NetBeansProjects/Calculadora/src/Core/CalculadoraTela.java calculadora/nbproject/private/private.properties compile.on.save=true user.properties.file=C:\\Users\\Bernardo\\AppData\\Roaming\\NetBeans\\8.1\\build.properties calculadora/nbproject/genfiles.properties build.xml.data.CRC32=c983daee build.xml.script.CRC32=93e5b08b build.xml.stylesheet.CRC32=8064a381@1.79.1.48 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=c983daee nbproject/build-impl.xml.script.CRC32=3d62b031 nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48 calculadora/nbproject/build-impl.xml Must set src.dir Must set test.src.dir Must set build.dir Must set dist.dir Must set build.classes.dir Must set dist.javadoc.dir Must set build.test.classes.dir Must set build.test.results.dir Must set build.classes.excludes Must set dist.jar Must set javac.includes No tests executed. Must set JVM to use for profiling in profiler.info.jvm Must set profiler agent JVM arguments in profiler.info.jvmargs.agent Must select some files in the IDE or set javac.includes To run this application from the command line without Ant, try: java -jar "${dist.jar.resolved}" Must select one file in the IDE or set run.class Must select one file in the IDE or set run.class Must select one file in the IDE or set debug.class Must select one file in the IDE or set debug.class Must set fix.includes This target only works when run from inside the NetBeans IDE. Must select one file in the IDE or set profile.class This target only works when run from inside the NetBeans IDE. This target only works when run from inside the NetBeans IDE. This target only works when run from inside the NetBeans IDE. Must select one file in the IDE or set run.class Must select some files in the IDE or set test.includes Must select one file in the IDE or set run.class Must select one file in the IDE or set applet.url Must select some files in the IDE or set javac.includes Some tests failed; see details above. Must select some files in the IDE or set test.includes Some tests failed; see details above. Must select some files in the IDE or set test.class Must select some method in the IDE or set test.method Some tests failed; see details above. Must select one file in the IDE or set test.class Must select one file in the IDE or set test.class Must select some method in the IDE or set test.method Must select one file in the IDE or set applet.url Must select one file in the IDE or set applet.url calculadora/nbproject/project.xml org.netbeans.modules.java.j2seproject Calculadora calculadora/nbproject/project.properties annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processor.options= annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form # This directory is removed when the project is cleaned: build.dir=build build.generated.dir=${build.dir}/generated build.generated.sources.dir=${build.dir}/generated-sources # Only compile against the classpath explicitly listed here: build.sysclasspath=ignore build.test.classes.dir=${build.dir}/test/classes build.test.results.dir=${build.dir}/test/results # Uncomment to specify the preferred debugger connection transport: #debug.transport=dt_socket debug.classpath=\ ${run.classpath} debug.test.classpath=\ ${run.test.classpath} # Os arquivos em build.classes.dir que devem ser exclu\u00eddos do jar de distribui\u00e7\u00e3o dist.archive.excludes= # This directory is removed when the project is cleaned: dist.dir=dist dist.jar=${dist.dir}/Calculadora.jar dist.javadoc.dir=${dist.dir}/javadoc excludes= includes=** jar.compress=false javac.classpath= # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false javac.external.vm=true javac.processorpath=\ ${javac.classpath} javac.source=1.8 javac.target=1.8 javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir} javac.test.processorpath=\ ${javac.test.classpath} javadoc.additionalparam= javadoc.author=false javadoc.encoding=${source.encoding} javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false javadoc.private=false javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= main.class=calculadora.Main manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false platform.active=default_platform run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} # Space-separated list of JVM arguments used when running the project. # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. # To set system properties for unit tests define test-sys-prop.name=value: run.jvmargs= run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} source.encoding=UTF-8 src.dir=src test.src.dir=test calculadora/build/classes/calculadora/Main.class calculadora/src/calculadora/Main.java /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package calculadora; import Core.CalculadoraCore; import Core.CalculadoraTela; /** * * @author Bernardo */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { CalculadoraTela tela = new CalculadoraTela(); tela.setVisible(true); tela.setLocationRelativeTo(null); } } Calculadora/manifest.mf Manifest-Version: 1.0 X-COMMENT: Main-Class will be added automatically by build Calculadora/build.xml Builds, tests, and runs the project Calculadora. calculadora/build/classes/.netbeans_update_resources calculadora/build/classes/.netbeans_automatic_build calculadora/src/Core/string.java /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Core; /** * * @author Bernardo */ class string { } calculadora/src/Core/CalculadoraTela.form calculadora/src/Core/CalculadoraTela.java /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Core; import java.util.HashSet; /** * * @author Bernardo */ public class CalculadoraTela extends javax.swing.JFrame { boolean flag = false; boolean umOuDois = false; boolean Menos = false; double Dig1; double Dig2; double Resultado; String digito = " "; CalculadoraCore core = new CalculadoraCore(); /** * Creates new form CalculadoraTela */ public CalculadoraTela() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jButton1 = new javax.swing.JButton(); bntSete = new javax.swing.JButton(); bntUM = new javax.swing.JButton(); bntQuatro = new javax.swing.JButton(); bntPonto = new javax.swing.JButton(); bntOito = new javax.swing.JButton(); bntDois = new javax.swing.JButton(); bntCinco = new javax.swing.JButton(); bntZero = new javax.swing.JButton(); bntNove = new javax.swing.JButton(); bntTres = new javax.swing.JButton(); bntSeis = new javax.swing.JButton(); bntIgual = new javax.swing.JButton(); bntVezes = new javax.swing.JButton(); bntDividir = new javax.swing.JButton(); bntMais = new javax.swing.JButton(); bntMenos = new javax.swing.JButton(); bntElevado = new javax.swing.JButton(); bntPorcento = new javax.swing.JButton(); btnApagar = new javax.swing.JButton(); bntRaiz = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); Tela = new javax.swing.JTextPane(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu2 = new javax.swing.JMenu(); jMenuItem2 = new javax.swing.JMenuItem(); jButton1.setText("jButton1"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Calculadora"); setBackground(new java.awt.Color(102, 153, 255)); setFont(new java.awt.Font("Arial", 2, 14)); // NOI18N bntSete.setText("7"); bntSete.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntSeteActionPerformed(evt); } }); bntUM.setText("1"); bntUM.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntUMActionPerformed(evt); } }); bntQuatro.setText("4"); bntQuatro.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntQuatroActionPerformed(evt); } }); bntPonto.setText("."); bntPonto.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntPontoActionPerformed(evt); } }); bntOito.setText("8"); bntOito.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntOitoActionPerformed(evt); } }); bntDois.setText("2"); bntDois.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntDoisActionPerformed(evt); } }); bntCinco.setText("5"); bntCinco.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntCincoActionPerformed(evt); } }); bntZero.setText("0"); bntZero.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntZeroActionPerformed(evt); } }); bntNove.setText("9"); bntNove.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntNoveActionPerformed(evt); } }); bntTres.setText("3"); bntTres.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntTresActionPerformed(evt); } }); bntSeis.setText("6"); bntSeis.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntSeisActionPerformed(evt); } }); bntIgual.setText("="); bntIgual.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntIgualActionPerformed(evt); } }); bntVezes.setText("×"); bntVezes.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntVezesActionPerformed(evt); } }); bntDividir.setText("÷ "); bntDividir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntDividirActionPerformed(evt); } }); bntMais.setText("+"); bntMais.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntMaisActionPerformed(evt); } }); bntMenos.setText("-"); bntMenos.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntMenosActionPerformed(evt); } }); bntElevado.setText("^"); bntElevado.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntElevadoActionPerformed(evt); } }); bntPorcento.setText("%"); bntPorcento.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntPorcentoActionPerformed(evt); } }); btnApagar.setText("C"); btnApagar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnApagarActionPerformed(evt); } }); bntRaiz.setText("R"); bntRaiz.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bntRaizActionPerformed(evt); } }); Tela.setEditable(false); Tela.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N Tela.addAncestorListener(new javax.swing.event.AncestorListener() { public void ancestorMoved(javax.swing.event.AncestorEvent evt) { } public void ancestorAdded(javax.swing.event.AncestorEvent evt) { TelaAncestorAdded(evt); } public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { } }); jScrollPane1.setViewportView(Tela); jMenuBar1.setToolTipText(""); jMenu2.setText("Sobre"); jMenu2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenu2ActionPerformed(evt); } }); jMenuItem2.setText("Trabalho de Programação Orientada a Objetos. 2016.1. Autor Bernardo Costa. "); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jMenu2.add(jMenuItem2); jMenuBar1.add(jMenu2); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(bntQuatro, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bntSete, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bntUM, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bntPonto, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(bntCinco, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bntOito, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bntDois, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bntZero, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(bntSeis, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bntNove, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bntTres, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bntIgual, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(bntVezes, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bntDividir, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bntMenos, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bntMais, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(bntPorcento, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnApagar, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bntElevado, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bntRaiz, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(jScrollPane1)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(btnApagar, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntPorcento, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntElevado, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntRaiz, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(bntDividir, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntVezes, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntMenos, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntMais, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(bntNove, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntSeis, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntTres, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntIgual, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(bntOito, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntCinco, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntDois, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntZero, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(bntSete, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntQuatro, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntUM, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bntPonto, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void bntUMActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntUMActionPerformed digito += "1"; Tela.setText(digito); }//GEN-LAST:event_bntUMActionPerformed private void bntTresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntTresActionPerformed digito += "3"; Tela.setText(digito); }//GEN-LAST:event_bntTresActionPerformed private void bntMaisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntMaisActionPerformed core.setOperador("+"); if(!umOuDois){ core.setDig1(Double.parseDouble(digito)); System.out.println(core.getDig1()); digito = null; digito = " "; Tela.setText("+"); umOuDois = true; } else{ Tela.setText("+"); core.setDig2(Double.parseDouble(digito)); System.out.println(core.getDig2()); digito = null; digito = " "; } }//GEN-LAST:event_bntMaisActionPerformed private void TelaAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_TelaAncestorAdded // TODO add your handling code here: }//GEN-LAST:event_TelaAncestorAdded private void bntPontoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntPontoActionPerformed if (!flag){ digito += "."; Tela.setText(digito); flag = true; }// TODO add your handling code here: }//GEN-LAST:event_bntPontoActionPerformed private void bntZeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntZeroActionPerformed digito += "0"; Tela.setText(digito); // TODO add your handling code here: }//GEN-LAST:event_bntZeroActionPerformed private void bntRaizActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntRaizActionPerformed core.setOperador("R"); if(!umOuDois){ core.setDig1(Double.parseDouble(digito)); System.out.println(core.getDig1()); digito = null; digito = " "; Tela.setText("R"); umOuDois = true; } else{ Tela.setText("R"); core.setDig2(Double.parseDouble(digito)); System.out.println(core.getDig2()); digito = null; digito = " "; } // TOD // TODO add your handling code here: }//GEN-LAST:event_bntRaizActionPerformed private void bntDoisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntDoisActionPerformed digito += "2"; Tela.setText(digito); // TODO add your handling code here: }//GEN-LAST:event_bntDoisActionPerformed private void bntMenosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntMenosActionPerformed core.setOperador("-"); if(!umOuDois){ core.setDig1(Double.parseDouble(digito)); System.out.println(core.getDig1()); digito = null; digito = " "; Tela.setText("-"); umOuDois = true; } else{ Tela.setText("-"); core.setDig2(Double.parseDouble(digito)); System.out.println(core.getDig2()); digito = null; digito = " "; } // TODO add your handling code here: }//GEN-LAST:event_bntMenosActionPerformed private void bntElevadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntElevadoActionPerformed core.setOperador("^"); if(!umOuDois){ core.setDig1(Double.parseDouble(digito)); System.out.println(core.getDig1()); digito = null; digito = " "; Tela.setText("^"); umOuDois = true; } else{ Tela.setText("^"); core.setDig2(Double.parseDouble(digito)); System.out.println(core.getDig2()); digito = null; digito = " "; }// TODO add your handling code here: }//GEN-LAST:event_bntElevadoActionPerformed private void bntQuatroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntQuatroActionPerformed digito += "4"; Tela.setText(digito); // TODO add your handling code here: }//GEN-LAST:event_bntQuatroActionPerformed private void bntCincoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntCincoActionPerformed digito += "5"; Tela.setText(digito); // TODO add your handling code here: }//GEN-LAST:event_bntCincoActionPerformed private void bntSeisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntSeisActionPerformed digito += "6"; Tela.setText(digito); // TODO add your handling code here: }//GEN-LAST:event_bntSeisActionPerformed private void bntVezesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntVezesActionPerformed core.setOperador("*"); if(!umOuDois){ core.setDig1(Double.parseDouble(digito)); System.out.println(core.getDig1()); digito = null; digito = " "; Tela.setText("x"); umOuDois = true; } else{ Tela.setText("x"); core.setDig2(Double.parseDouble(digito)); System.out.println(core.getDig2()); digito = null; digito = " "; } // TODO add your handling code here: }//GEN-LAST:event_bntVezesActionPerformed private void bntPorcentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntPorcentoActionPerformed core.setOperador("%"); if(!umOuDois){ core.setDig1(Double.parseDouble(digito)); System.out.println(core.getDig1()); digito = null; digito = " "; Tela.setText("%"); umOuDois = true; } else{ Tela.setText("%"); core.setDig2(Double.parseDouble(digito)); System.out.println(core.getDig2()); digito = null; digito = " "; Tela.setText("%"); } }//GEN-LAST:event_bntPorcentoActionPerformed private void bntSeteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntSeteActionPerformed digito += "7"; Tela.setText(digito); // TODO add your handling code here: }//GEN-LAST:event_bntSeteActionPerformed private void bntOitoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntOitoActionPerformed digito += "8"; Tela.setText(digito); // TODO add your handling code here: }//GEN-LAST:event_bntOitoActionPerformed private void bntNoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntNoveActionPerformed digito += "9"; Tela.setText(digito); ; // TODO add your handling code here: }//GEN-LAST:event_bntNoveActionPerformed private void bntDividirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntDividirActionPerformed core.setOperador("/"); if(!umOuDois){ core.setDig1(Double.parseDouble(digito)); System.out.println(core.getDig1()); digito = null; digito = " "; Tela.setText("÷"); umOuDois = true; } else{ Tela.setText("÷"); core.setDig2(Double.parseDouble(digito)); System.out.println(core.getDig2()); digito = null; digito = " "; } }//GEN-LAST:event_bntDividirActionPerformed private void btnApagarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnApagarActionPerformed core.setOperador("+"); umOuDois = false; Tela.setText(" "); // TODO add your handling code here: core.setDig1(0); core.setDig2(0); core.setResultado(0); digito = null; digito = " "; }//GEN-LAST:event_btnApagarActionPerformed private void bntIgualActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntIgualActionPerformed core.setDig2(Double.parseDouble(digito)); core.seletor(); digito = null; digito = " "; System.out.println(core.getResultado()); Tela.setText(String.valueOf(core.getResultado())); }//GEN-LAST:event_bntIgualActionPerformed private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu2ActionPerformed }//GEN-LAST:event_jMenu2ActionPerformed private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jMenuItem2ActionPerformed /** * @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(CalculadoraTela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(CalculadoraTela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(CalculadoraTela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(CalculadoraTela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new CalculadoraTela().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextPane Tela; private javax.swing.JButton bntCinco; private javax.swing.JButton bntDividir; private javax.swing.JButton bntDois; private javax.swing.JButton bntElevado; private javax.swing.JButton bntIgual; private javax.swing.JButton bntMais; private javax.swing.JButton bntMenos; private javax.swing.JButton bntNove; private javax.swing.JButton bntOito; private javax.swing.JButton bntPonto; private javax.swing.JButton bntPorcento; private javax.swing.JButton bntQuatro; private javax.swing.JButton bntRaiz; private javax.swing.JButton bntSeis; private javax.swing.JButton bntSete; private javax.swing.JButton bntTres; private javax.swing.JButton bntUM; private javax.swing.JButton bntVezes; private javax.swing.JButton bntZero; private javax.swing.JButton btnApagar; private javax.swing.JButton jButton1; private javax.swing.JMenu jMenu2; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuItem jMenuItem2; private javax.swing.JScrollPane jScrollPane1; // End of variables declaration//GEN-END:variables } calculadora/src/Core/CalculadoraCore.java /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Core; /** * * @author Bernardo */ public class CalculadoraCore{ //atributor obrigatorios private double Dig1 = 0; //armazena um numero private double Dig2 = 0; //armazena um numero private static double Resultado = 0; //armazena o resultado de uma operacao //atributos auxiliares private int Operador; //armazena o operador //metodos obrigatorios para o trabalho //set e get public double getDig1(){ return Dig1; } public double getDig2(){ return Dig2; } public double getResultado(){ return Resultado; } public void setDig1(double dig1){ Dig1 = dig1; } public void setDig2(double dig2){ Dig2 = dig2; } public void setResultado(double resultado){ Resultado = resultado; } ////set e get operador public void setOperador(String teste){ if((teste.charAt(0) == '+')&&(teste.length() == 1)){ Operador = 1; return; } if((teste.charAt(0) == '-')&&(teste.length() == 1)){ Operador = 2; return; } if((teste.charAt(0) == '*')&&(teste.length() == 1)){ Operador = 3; return; } if((teste.charAt(0) == '/')&&(teste.length() == 1)){ Operador = 4; return; } if((teste.charAt(0) == '%')&&(teste.length() == 1)){ Operador = 5; return; } if((teste.charAt(0) == '^')&&(teste.length() == 1)){ Operador = 6; return; } if((teste.charAt(0) == 'R')&&(teste.length() == 1)){ Operador = 7; return; } if((teste.charAt(0) == '=')&&(teste.length() == 1)){ Operador = 8; return; } else{ System.out.println("Expressao invalida"); System.exit(1); } } public int getOperador(){ return Operador; } //seletor public void seletor(){ if(Operador == 1) somador(); if(Operador == 2) subtrator(); if(Operador == 3) multiplicador(); if(Operador == 4) divisor(); if(Operador == 5) porcentagem(); if(Operador == 6) exponenciacao(); if(Operador == 7) radiciacao(); if(Operador == 8) igual(); } //reslizam cada uma das possiveis operacoes public void somador(){ Resultado = Dig1 + Dig2; Dig1 = Resultado; } public void subtrator(){ Resultado = Dig1 - Dig2; Dig1 = Resultado; } public void multiplicador(){ Resultado = Dig1 * Dig2; Dig1 = Resultado; } public void divisor(){ if(Dig2 != 0){ Resultado = Dig1 / Dig2; Dig1 = Resultado; } else{ System.out.println("Expressao invalida"); System.exit(1); } } public void porcentagem(){ if(Dig2 != 0){ Resultado = Dig1*(1.0/Dig2); Dig1 = Resultado; } else{ System.out.println("Expressao invalida"); System.exit(1); } } public void exponenciacao(){ Resultado = Math.pow(Dig1, Dig2); Dig1 = Resultado; } public void radiciacao(){ if(Dig1 >= 0){ Resultado = Math.pow(Dig1, (1.0/Dig2)); Dig1 = Resultado; } else { System.out.println("Expressao invalida"); System.exit(1); } } public void igual(){ int teste; impressaoResultado(); //System.out.println("Deseja Continuar? 1 p/ Sim e 0 p/ Nao"); //teste = input.nextInt(); //if(teste == 0) System.exit(0); } //impressao do resultado public static void impressaoResultado(){ System.out.printf("%.2f\n", Resultado); } } calculadora/build/classes/Core/CalculadoraTela$17.class calculadora/build/classes/Core/CalculadoraCore.class calculadora/build/classes/Core/CalculadoraTela$14.class calculadora/build/classes/Core/CalculadoraTela$3.class calculadora/build/classes/Core/CalculadoraTela$8.class calculadora/build/classes/Core/CalculadoraTela$20.class calculadora/build/classes/Core/CalculadoraTela$19.class calculadora/build/classes/Core/CalculadoraTela$12.class calculadora/build/classes/Core/CalculadoraTela$5.class calculadora/build/classes/Core/CalculadoraTela$11.class calculadora/build/classes/Core/CalculadoraTela$6.class calculadora/build/classes/Core/CalculadoraTela$23.class calculadora/build/classes/Core/CalculadoraTela.form calculadora/build/classes/Core/CalculadoraTela$15.class calculadora/build/classes/Core/CalculadoraTela$9.class calculadora/build/classes/Core/CalculadoraTela$2.class calculadora/build/classes/Core/CalculadoraTela$16.class calculadora/build/classes/Core/CalculadoraTela$1.class calculadora/build/classes/Core/CalculadoraTela$24.class calculadora/build/classes/Core/CalculadoraTela$10.class calculadora/build/classes/Core/CalculadoraTela$7.class calculadora/build/classes/Core/string.class calculadora/build/classes/Core/CalculadoraTela$22.class calculadora/build/classes/Core/CalculadoraTela.class calculadora/build/classes/Core/CalculadoraTela$21.class calculadora/build/classes/Core/CalculadoraTela$13.class calculadora/build/classes/Core/CalculadoraTela$18.class calculadora/build/classes/Core/CalculadoraTela$4.class
Compartilhar