add the order restriction
This commit is contained in:
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -1,15 +1,12 @@
|
|||||||
package me.jj97181818.ch05_foodmenueventhw;
|
package me.jj97181818.ch05_foodmenueventhw;
|
||||||
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.w3c.dom.Text;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener {
|
public class MainActivity extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener {
|
||||||
@ -50,13 +47,34 @@ public class MainActivity extends AppCompatActivity implements CompoundButton.On
|
|||||||
public void takeOrder(View v) {
|
public void takeOrder(View v) {
|
||||||
String msg = "";
|
String msg = "";
|
||||||
|
|
||||||
|
if (selected.size() == 3) {
|
||||||
for (CompoundButton chk:selected)
|
for (CompoundButton chk:selected)
|
||||||
msg += "\n" + chk.getText();
|
msg += "\n" + chk.getText();
|
||||||
|
|
||||||
if(msg.length() > 0)
|
msg = "你點購的餐點是:" + msg + "\n總共是 50 元。";
|
||||||
msg = "你點購的餐點是:" + msg;
|
}
|
||||||
else
|
else if (selected.size() == 4) {
|
||||||
|
for (CompoundButton chk:selected)
|
||||||
|
msg += "\n" + chk.getText();
|
||||||
|
|
||||||
|
msg = "你點購的餐點是:" + msg + "\n總共是 60 元。";
|
||||||
|
}
|
||||||
|
else if (selected.size() == 0){
|
||||||
msg = "請點餐!";
|
msg = "請點餐!";
|
||||||
|
}
|
||||||
|
else if (selected.size() > 4) {
|
||||||
|
msg = "點餐不得點超過 4 樣。";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
msg = "點餐不得點少於 3 樣。";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// if(msg.length() > 0)
|
||||||
|
//
|
||||||
|
// else
|
||||||
|
// msg = "請點餐!";
|
||||||
|
|
||||||
((TextView) findViewById(R.id.showOrder)).setText(msg);
|
((TextView) findViewById(R.id.showOrder)).setText(msg);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginBottom="165dp"
|
android:layout_marginBottom="165dp"
|
||||||
android:text="請點餐"
|
android:text="請點餐"
|
||||||
android:textSize="30sp"
|
android:textSize="20sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
Reference in New Issue
Block a user