- إنضم
- 22 يونيو 2014
- رقم العضوية
- 2301
- المشاركات
- 3,166
- مستوى التفاعل
- 5,959
- النقاط
- 724
- أوسمتــي
- 5
- العمر
- 34
- الإقامة
- عالم الأساطير
- توناتي
- 2,480
- الجنس
- ذكر
LV
1
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
/** * This app displays an order form to order coffee. */
public class MainActivity extends AppCompatActivity {
int quantity = 2;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void submitOrder (View view) {
int price = calculatePrice();
String priceMessage = creatOrderSummary(price);
display message(priceMessage);
}
private int calculatePrice () {
int price = quantity * 5;
return price;
}
public void createOrderSummary(View view) {
String priceMessage = "The name: Kaptain kamel"
priceMessage =priceMessage + "\nThe Quantity: " + quantity;
priceMessage =priceMessage + "\nTotal: $ " + price;
priceMessage = priceMessage + "\n thank you";
return priceMessage;
displayprice(priceMessage ); }
Private void increment (View view)
{
quantity = quantity + 1
display(quantity)
}
Private void descrement (View view) {
quantity = quantity - 1
display(quantity)
}
private void display(int number) {
TextView quantityTextView = (TextView) findViewById( R.id.quantity_text_view);
quantityTextView.setText("" + number); }
private void displayPrice(int number)
{ TextView priceTextView = (TextView) findViewById( R.id.quantity_text_price_text_view); priceTextView.setText(NnumbeFormat.getCurrencyInstance().format(number)); }
private void displayMessage(String message) {
TextView priceTextView = (TextView) findViewById(R.id.price_text_view);
priceTextView.setText(message);
}