Discover

Topics

Calculadora Gigante Básica

Calculadora Gigante Básica APK

Calculadora Gigante Básica APK

2 FreeEduDavila´s DevApp ⇣ Download APK (1.03 MB)

Example App Calculator used in class Pronatec Estacio de Sa

What's Calculadora Gigante Básica APK?

Calculadora Gigante Básica is a app for Android, It's developed by EduDavila´s DevApp author.
First released on google play in 9 years ago and latest version released in 6 years ago.
This app has 3.3K download times on Google play and rated as 2.17 stars with 6 rated times.
This product is an app in Education category. More infomartion of Calculadora Gigante Básica on google play
Prof. Eduardo D'Avila
Material de aula da disciplina Android Mobile e Java POO
Curso Técnico Pronatec Estácio de Sá / Campus WestShopping Campo Grande RJ



/**
* Created by Eduardo on 26/06/2015.
*/
public class Calculadora {
public double operando;
private double operandoAnterior;
private String operadorAnterior = "";


public void realizarOperacao(String operadorAtual) {
realizarOperacaoAnterior();
operandoAnterior = operando;
operadorAnterior = operadorAtual;
}

public void realizarOperacaoAnterior() {
if (!operadorAnterior.equals("")) {
if (operadorAnterior.equals("+")) {
operando = operandoAnterior + operando;
} else if (operadorAnterior.equals("-")) {
operando = operandoAnterior - operando;
} else if (operadorAnterior.equals("÷")) {
if (operando != 0)
operando = operandoAnterior / operando;
} else if (operadorAnterior.equals("*")) {
operando = operandoAnterior * operando;
}
}
}




}


----------------------------------------------------------------------------------------------------------------------------------------


import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;


public class MainActivity extends Activity {
Typeface fonteDigital;
TextView txtVisor;
// Button bt0, bt1, bt2, bt3, bt4, bt5, bt6, bt7, bt8, bt9;
// int nbt0 = 0, nbt1 = 1, nbt2 = 2, nbt3 = 3, nbt4 = 4, nbt5 = 5, nbt6 = 6, nbt7 = 7, nbt8 = 8, nbt9 = 9;
boolean digitandoNovoNumero = true;
Button botaoTocado;
Calculadora calc = new Calculadora();


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtVisor = (TextView) findViewById(R.id.txtVisor);
fonteDigital = Typeface.createFromAsset(getAssets(), "digital.ttf");
txtVisor.setTypeface(fonteDigital);


}


public void digitarNumero(View view) {
botaoTocado = (Button) view;
if (digitandoNovoNumero) {
txtVisor.setText(botaoTocado.getText());
digitandoNovoNumero = false;
} else {
txtVisor.setText(txtVisor.getText() + botaoTocado.getText().toString());
}

}


public void digitarOperacao(View view) {
botaoTocado = (Button) view;
double operandoVisor = Double.parseDouble(txtVisor.getText().toString());
calc.operando = operandoVisor;
calc.realizarOperacao(botaoTocado.getText().toString());
txtVisor.setText(String.valueOf(calc.operando));

digitandoNovoNumero = true;

}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
}


-------------------------------------------------------------