Last active
December 17, 2015 11:49
-
-
Save emedinaa/5605012 to your computer and use it in GitHub Desktop.
Fundamentos Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.area51.projects.pappjavafundamentos; | |
public class Nino extends Persona | |
{ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.area51.projects.pappjavafundamentos; | |
import android.util.Log; | |
public class Persona { | |
private int edad=10; | |
private String nombre="Eduardo"; | |
private String apellidos ="Medina"; | |
private void correr() | |
{ | |
Log.v("console","CORRER"); | |
}; | |
public void dormir() | |
{ | |
} | |
public int sumar(int _valor1,int _valor2) | |
{ | |
return _valor1+_valor2; | |
} | |
public int getEdad() { | |
return edad; | |
} | |
public void setEdad(int edad) { | |
this.edad = edad; | |
} | |
public String getNombre() { | |
return nombre; | |
} | |
public void setNombre(String nombre) { | |
this.nombre = nombre; | |
} | |
public String getApellidos() { | |
return apellidos; | |
} | |
public void setApellidos(String apellidos) { | |
this.apellidos = apellidos; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.area51.pappactivity; | |
import android.net.Uri; | |
import android.os.Bundle; | |
import android.app.Activity; | |
import android.content.ActivityNotFoundException; | |
import android.content.Intent; | |
import android.view.Menu; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.widget.Button; | |
import android.widget.EditText; | |
public class LoginActivity extends Activity implements OnClickListener{ | |
private Button btnLogin; | |
private EditText txtUserName, txtPassword; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_login); | |
//inicializando controles | |
btnLogin=(Button)findViewById(R.id.btnLogin); | |
txtUserName=(EditText)findViewById(R.id.txtUserName); | |
txtPassword=(EditText)findViewById(R.id.txtPassword); | |
//events | |
btnLogin.setOnClickListener(this); | |
/*Intent intent=new Intent(this, MainActivity.class); | |
startActivity(intent);*/ | |
/*String url="http://area51.pe/"; | |
Intent intent=new Intent(Intent.ACTION_VIEW); | |
intent.setData(Uri.parse(url));*/ | |
//startActivity(intent); | |
//-------------------------------- | |
/*try { | |
String phoneNumber="tel:976052576"; | |
Intent intent2=new Intent(Intent.ACTION_DIAL); | |
intent2.setData(Uri.parse(phoneNumber)); | |
startActivity(intent2); | |
} catch (ActivityNotFoundException e) { | |
// TODO: handle exception | |
}*/ | |
} | |
@Override | |
protected void onPause() { | |
// TODO Auto-generated method stub | |
super.onPause(); | |
} | |
@Override | |
protected void onStop() { | |
// TODO Auto-generated method stub | |
super.onStop(); | |
} | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
// Inflate the menu; this adds items to the action bar if it is present. | |
getMenuInflater().inflate(R.menu.login, menu); | |
return true; | |
} | |
@Override | |
public void onClick(View e) | |
{ | |
// TODO Auto-generated method stub | |
if(e.getId()==R.id.btnLogin) | |
{ | |
//acciòn | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.area51.projects.pappjavafundamentos; | |
import java.util.Random; | |
import android.os.Bundle; | |
import android.app.Activity; | |
import android.util.Log; | |
import android.view.Menu; | |
public class MainActivity extends Activity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
//codeando | |
// Tipos de Datos ----------------------------------- | |
byte a=100; | |
byte b=-50; | |
short s=10000; | |
short r=-20000; | |
int sueldo=5000; | |
double precio=200.50; | |
boolean casado=false;//true | |
Character letterA='A'; | |
String mensaje="Hola Mundo"; | |
//Arrays -------------------------------------------- | |
String[] dias={"lunes","martes","miercoles","jueves","viernes"}; | |
double[] pares={2,4,6,8,10}; | |
//CONDICIONALES ------------------------------------------ | |
int numero=35; | |
if(numero>20 && numero<40) | |
{ | |
Log.v("console","En este rango"); | |
}else | |
{ | |
Log.v("console","No esta en el rango"); | |
} | |
int edad=20; | |
if(edad<18) | |
{ | |
Log.v("console","menor de edad"); | |
}else if(edad==18) | |
{ | |
Log.v("console","tiene 18"); | |
}else if(edad>18) | |
{ | |
Log.v("console","mayor 18"); | |
} | |
if(casado) | |
{ | |
} | |
if(numero%2==0) | |
{ | |
System.out.print("Es un número par"); | |
Log.v("console","Es un número par"); | |
}else | |
{ | |
System.out.print("Es un número impar"); | |
Log.v("console","Es un número impar"); | |
} | |
/* Log.v("console",mensaje);//ctrl+alt+flecha abajo | |
Log.v("console","letterA "+letterA);//ctrl+flecha abajo | |
Log.v("console","casado "+casado); | |
Log.v("console","dias length "+dias.length); | |
Log.v("console","dias [0] "+dias[0]); | |
Log.v("console","dias ùltimo elemento "+dias[dias.length-1]); | |
Log.v("console","pares "+pares[0]); | |
Log.v("console","precio"+precio);*/ | |
} | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
// Inflate the menu; this adds items to the action bar if it is present. | |
getMenuInflater().inflate(R.menu.main, menu); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment