package com.example.ghomi.chapter3_2;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.RadioGroup;
import android.view.View;
import android.widget.CheckBox;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    CheckBox chkW, chkS,chkJ;
    TextView outView;
    RadioGroup rg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        chkW = (CheckBox)findViewById(R.id.chkWater);
               chkS = (CheckBox)findViewById(R.id.chkSoda);
               chkJ = (CheckBox)findViewById(R.id.chkJuice);
               outView = (TextView)findViewById(R.id.Result);
               rg = (RadioGroup)findViewById(R.id.pizzaSize);
    }
    public void onClickButton(View v) {
               int sum = 0;
               if(chkW.isChecked())
                       sum += 1200;
               if(chkS.isChecked())
                       sum += 1500;
               if(chkJ.isChecked())
                       sum += 2000;
               RadioButton selectRadio = (RadioButton) findViewById(rg.getCheckedRadioButtonId());
               switch(selectRadio.getId()) {
                        case R.id.smallButton:
                               sum += 15000;
                               break;
                        case R.id.mediumButton:
                               sum += 18000;
                               break;
                        case R.id.largeButton:
                               sum += 20000;
               }
               outView.setText("price is :");
               outView.setText(outView.getText() + Integer.toString(sum));
            }
}
