Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can anyone help with this? I got this so far, but I don't know how to do it. __________________________________________________________________________________________________ package com.example.danielchoo.lab2; import android.support.v7.app.AppCompatActivity; import android.os.Bundle;

image text in transcribed

Can anyone help with this?

I got this so far, but I don't know how to do it.

__________________________________________________________________________________________________

package com.example.danielchoo.lab2; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.SeekBar; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity { //Define the Radio group 1 and 2 RadioGroup myRG1, myRG2; // Pizza crust and order option RadioButton crispy, thick, soggy, restaurant, deliver, pickup; // Pizza topping options CheckBox myCB1, myCB2, myCB3, myCB4; // Pizza size SeekBar mySB; // text view for price TextView tv, tv1, tv2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); myRG1 = (RadioGroup)findViewById(R.id.radiogroup1); myRG2 = (RadioGroup)findViewById(R.id.radiogroup2); myCB1 = (CheckBox)findViewById(R.id.checkBox); myCB2 = (CheckBox)findViewById(R.id.checkBox2); myCB3 = (CheckBox)findViewById(R.id.checkBox3); myCB4 = (CheckBox)findViewById(R.id.checkBox4); mySB = (SeekBar)findViewById(R.id.seekBar); tv = (TextView)findViewById(R.id.textView5); // pizza size inch tv1 = (TextView)findViewById(R.id.TotalPrice); tv2 = (TextView)findViewById(R.id.Price); // total price present // Setting Radio button group 1 crispy = (RadioButton)findViewById(R.id.crispy); thick = (RadioButton)findViewById(R.id.thick); soggy = (RadioButton)findViewById(R.id.soggy); // Setting Radio button group 2 restaurant = (RadioButton)findViewById(R.id.restaurant); pickup = (RadioButton)findViewById(R.id.pickup); deliver = (RadioButton)findViewById(R.id.deliver); // Radio Group of Crust myRG1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { int currentId = myRG1.getCheckedRadioButtonId(); RadioButton currentRB = (RadioButton)findViewById(currentId); Toast.makeText(getApplicationContext(), currentRB.getText(), Toast.LENGTH_SHORT); } }); // Radio Group of Togo or no myRG2.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { int currentId = myRG2.getCheckedRadioButtonId(); RadioButton currentRB = (RadioButton)findViewById(currentId); Toast.makeText(getApplicationContext(), currentRB.getText(), Toast.LENGTH_SHORT); } }); myCB1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(buttonView == myCB1 && isChecked) Toast.makeText(getApplicationContext(), myCB1.getText(), Toast.LENGTH_SHORT).show(); } }); myCB2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(buttonView == myCB2 && isChecked) Toast.makeText(getApplicationContext(), myCB2.getText(), Toast.LENGTH_SHORT).show(); } }); myCB3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(buttonView == myCB3 && isChecked) Toast.makeText(getApplicationContext(), myCB3.getText(), Toast.LENGTH_SHORT).show(); } }); myCB4.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(buttonView == myCB4 && isChecked) Toast.makeText(getApplicationContext(), myCB4.getText(), Toast.LENGTH_SHORT).show(); } }); mySB.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { tv.setText(progress + " in"); // tv2.setText(progress(PizzaPrice) + "$ "); } @Override public void onStartTrackingTouch(SeekBar seekBar) { Toast.makeText(MainActivity.this,"started", Toast.LENGTH_SHORT); } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); // setting Price text Listener tv2.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { } }); } class PizzaPrice { private int diameter; private double price; public PizzaPrice(int size, double cost) { diameter = size; price = cost; } public int getSize() { return diameter; } public double getPrice() { return price; } public double unitPrice() { double radius; double pizzaSize; double pricePerSqIn; radius = 0.5 * diameter; pizzaSize = Math.PI * radius * radius; pricePerSqIn = price / pizzaSize; return pricePerSqIn; } } /* private double Size() { double diameter = 0; double area = (diameter/2)*(diameter/2) * Math.PI; double price = area * 0.05; // pizza price per square inch int id = myRG1.getCheckedRadioButtonId(); switch(id) { case R.id.crispy: break; case R.id.thick: tv2.setText(" $" + price + 2.50); break; case R.id.soggy: tv2.setText(" $" + price + 5.00); break; } return 0; } */ } 

xml file

________________________________________________

                        

Create a pizza pricing application shown as follows: MainActivity Crust Topping Crispy Thick Soggy Anchovies Pineapple Garlic Okra To go or no? At restaurant O Pickup Deliver Size 29 in $33.03 o o o $.05 per square inch $.05 per topping per square inch Different crust types No surcharge for crispy $2.50 extra for thick crust $5.00 extra for soggy crust - o Different delivery options At the restaurant or pickup, no charge Delivery charge is S3.00 - The application will react whenever the state of a control changes Create a pizza pricing application shown as follows: MainActivity Crust Topping Crispy Thick Soggy Anchovies Pineapple Garlic Okra To go or no? At restaurant O Pickup Deliver Size 29 in $33.03 o o o $.05 per square inch $.05 per topping per square inch Different crust types No surcharge for crispy $2.50 extra for thick crust $5.00 extra for soggy crust - o Different delivery options At the restaurant or pickup, no charge Delivery charge is S3.00 - The application will react whenever the state of a control changes

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

What are the key stages of WP/WIP/SWP?

Answered: 1 week ago