package cs1410.assignment08;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Planets extends Activity implements OnClickListener {
/** Called when the activity is first created. */
private EditText display;
private TextView tv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
((Button) findViewById(R.id.button1)).setOnClickListener(this);
((Button) findViewById(R.id.button2)).setOnClickListener(this);
((Button) findViewById(R.id.button3)).setOnClickListener(this);
((Button) findViewById(R.id.button4)).setOnClickListener(this);
((Button) findViewById(R.id.button5)).setOnClickListener(this);
((Button) findViewById(R.id.button6)).setOnClickListener(this);
((Button) findViewById(R.id.button7)).setOnClickListener(this);
((Button) findViewById(R.id.button8)).setOnClickListener(this);
display = (EditText) findViewById(R.id.editText1);
tv = (TextView) findViewById(R.id.textView1);
}
public void onClick(View v) {
Button b = (Button) v;
String buttonLabel = b.getText().toString();
//tv.setText("...");
if(buttonLabel.equals("Mercury"))
{
display.setText ("Mercury is about .387 AU from Sun");
tv.setText("Mercury was named after the god Hermes, the messenger of the gods in Roman mythology.");
}
if(buttonLabel.equals("Venus"))
{
display.setText ("Venus is about .722 AU from Sun");
tv.setText("Venus is named after the Roman goddess of love and beauty.");
}
else if(buttonLabel.equals("Earth"))
{
display.setText ("Earth is 1 AU from the Sun");
tv.setText("Everything you've ever known, everyone you've ever loved, every king, queen, every war and disease...");
}
if(buttonLabel.equals("Mars"))
{
display.setText ("Mars is about 1.52 AU from Sun");
tv.setText("Mars was named after Areas, the Roman god of War.");
}
if(buttonLabel.equals("Jupiter"))
{
display.setText ("Jupiter is about 5.20 AU from Sun");
tv.setText("Jupiter, the largest planet in the Solar System, was appropriately named for the Roman King of Gods.");
}
if(buttonLabel.equals("Saturn"))
{
display.setText ("Saturn is about 9.58 AU from Sun");
tv.setText("Saturn is named after Cronus, the god of Architecture.");
}
if(buttonLabel.equals("Uranus"))
{
display.setText ("Uranus is about 19.20 AU from Sun");
tv.setText("Uranus was the Roman god of the Heavens.");
}
if(buttonLabel.equals("Neptune"))
{
display.setText ("Neptune is about 30.10 AU from Sun");
tv.setText("Neptune was named after Poseidon, the god of the Seas, and with the blue color of its atmosphere, this is fitting.");
}
}
}