Created
April 11, 2017 21:44
-
-
Save kristinababikova/87504a546285d90f55c4b397e1eb7f1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.android.absinthequiz; | |
import android.content.Intent; | |
import android.net.Uri; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.text.Editable; | |
import android.view.View; | |
import android.widget.CheckBox; | |
import android.widget.EditText; | |
import android.widget.RadioButton; | |
import android.widget.TextView; | |
import android.widget.Toast; | |
import org.w3c.dom.Text; | |
import static com.example.android.absinthequiz.R.string.herbs; | |
public class MainActivity extends AppCompatActivity { | |
private String text_herbs_1; | |
private String text_herbs_2; | |
private String text_herbs_3; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
} | |
public void submitAnswers (View view) { | |
int count = 0; | |
EditText herbField = (EditText) findViewById(R.id.editText_herbs); | |
Editable nameEditable = herbField.getText(); | |
String herbs = nameEditable.toString(); | |
if (!"".equals(herbs)) { | |
//oddelene ciarkou | |
String[] parts = herbs.split(","); | |
text_herbs_1 = parts[0]; | |
text_herbs_1 = parts[1]; | |
text_herbs_1 = parts[2]; | |
if ("anise".equals(text_herbs_1) || "anýz".equals(text_herbs_1)) { | |
count++; | |
} | |
if ("fennyl".equals(text_herbs_2) || "fenykel".equals(text_herbs_2)) { | |
count++; | |
} | |
if ("wormwood".equals(text_herbs_3) || "vudvorm".equals(text_herbs_3)) { | |
count++; | |
} | |
} | |
RadioButton italyRadioButton = (RadioButton) findViewById(R.id.radioButton_Italy); | |
boolean isItaly = italyRadioButton.isChecked(); | |
if (isItaly) { | |
count++; | |
} | |
RadioButton millionsRadioButton = (RadioButton) findViewById(R.id.radioButton_36millions); | |
boolean isMillions = millionsRadioButton.isChecked(); | |
if (isMillions) { | |
count++; | |
} | |
EditText percentField = (EditText) findViewById(R.id.editText_percentage); | |
Editable percentEditable = percentField.getText(); | |
String percent = percentEditable.toString(); | |
if (!"".equals(percent)) { | |
if ("15".equals(percent)) { | |
count++; | |
} | |
} | |
EditText artistField = (EditText) findViewById(R.id.editText_herbs); | |
Editable artistEditable = herbField.getText(); | |
String artist = artistEditable.toString(); | |
if (!"".equals(artist)) { | |
if ("Picasso".equals(artist)) { | |
count++; | |
} | |
} | |
Toast.makeText(this, "You've got "+count+"/8", Toast.LENGTH_LONG).show(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<string name="app_name">ABSINTHE QUIZ</string> | |
<string name="question1">1. Question</string> | |
<string name="question2">2. Question</string> | |
<string name="question3">3. Question</string> | |
<string name="question4">4. Question</string> | |
<string name="question5">5. Question</string> | |
<string name="million0">0,7 million</string> | |
<string name="million3">3,4 million</string> | |
<string name="million17">17,8 million</string> | |
<string name="million36">36 million</string> | |
<string name="million48">48 million</string> | |
<string name="italy">Italy</string> | |
<string name="sweden">Sweden</string> | |
<string name="netherlands">Netherlands</string> | |
<string name="island">Island</string> | |
<string name="spain">Spain</string> | |
<string name="question1_text">"Absinthe is absinthe thanks to a special trio of herbs which are used in it´s creation. These herbs are usually referred to as the HOLY TRINITY OF ABSINTHE. To help you, we offer you pictures of the particular herbs. Can you name them? "</string> | |
<string name="question2_text">By 1910, the French were drinking 5 million litres of wine – annual consumption. What was the annual consumption of absinthe in that year?</string> | |
<string name="question3_text">In which country is REAL absinthe legal, but you can´t buy it in any normal or liquor shops? Instead, you can buy it in smart-shops and head-shops, shops designed to sell legal and semi-legal drugs and narcotics?</string> | |
<string name="question4_text">Math: An absinthe has 90% alcohol content. We prepare a serving of 20ml and mix it with 1 deciliter of water. How strong is the final solution?</string> | |
<string name="question5_text">Here you see three different pieces of art on the absinthe thematic. They were all made by the same author. Can you name him?</string> | |
<string name="percentage">%</string> | |
<string name="artist">artist</string> | |
<string name="herbs">herbs</string> | |
<string name="imageView_herbs1">image_herbs1</string> | |
<string name="imageView_herbs2">image_herbs2</string> | |
<string name="imageView_herbs3">image_herbs3</string> | |
<string name="imageView_WomanDrinkingAbsinthe1901">image_womanDrinkingAbsinthe_1901</string> | |
<string name="imageView_bottleOfPernodAndGlass1912">image_bottleOfPernodAndGlass_1912</string> | |
<string name="imageView_absintheGlass1914">image_absintheGlass_1914</string> | |
<string name="evaluate">evaluate</string> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:id="@+id/activity_main" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context="com.example.android.absinthequiz.MainActivity" | |
tools:layout_editor_absoluteX="8dp" | |
tools:layout_editor_absoluteY="8dp"> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:orientation="vertical" | |
android:paddingBottom="@dimen/activity_vertical_margin" | |
android:paddingLeft="@dimen/activity_horizontal_margin" | |
android:paddingRight="@dimen/activity_horizontal_margin" | |
android:paddingTop="@dimen/activity_vertical_margin" | |
tools:context="com.example.android.quiz_udacity.MainActivity"> | |
<TextView | |
android:id="@+id/question1" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="@string/question1" | |
android:fontFamily="sans-serif" | |
android:textSize="18sp" | |
android:textStyle="normal|bold" | |
android:layout_marginTop="8dp" | |
android:layout_marginBottom="8dp" | |
android:textAlignment="viewStart" | |
android:layout_gravity="start"/> | |
<TextView | |
android:id="@+id/question1_text" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center" | |
android:layout_marginBottom="16dp" | |
android:text="@string/question1_text" /> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:orientation="horizontal"> | |
<ImageView | |
android:id="@+id/imageView_Aniseed" | |
android:layout_width="0dp" | |
android:layout_weight="1" | |
android:layout_height="60dp" | |
android:src="@drawable/aniseed" | |
android:contentDescription="@string/imageView_herbs1" /> | |
<ImageView | |
android:id="@+id/imageView_Fennel" | |
android:layout_width="0dp" | |
android:layout_weight="1" | |
android:layout_height="60dp" | |
android:src="@drawable/fennel" | |
android:contentDescription="@string/imageView_herbs2" /> | |
<ImageView | |
android:id="@+id/imageView_Wormwood" | |
android:layout_width="0dp" | |
android:layout_weight="1" | |
android:layout_height="60dp" | |
android:src="@drawable/wormwood" | |
android:contentDescription="@string/imageView_herbs3" /> | |
</LinearLayout> | |
<EditText | |
android:id="@+id/editText_herbs" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:ems="10" | |
android:hint="@string/herbs" | |
android:inputType="text" /> | |
<TextView | |
android:id="@+id/question2" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="@string/question2" | |
android:fontFamily="sans-serif" | |
android:textSize="18sp" | |
android:layout_marginTop="8dp" | |
android:layout_marginBottom="8dp" | |
android:textAlignment="viewStart" | |
android:layout_gravity="start" | |
android:textStyle="normal|bold"/> | |
<TextView | |
android:id="@+id/question2_text" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="16dp" | |
android:text="@string/question2_text" /> | |
<RadioButton | |
android:id="@+id/radioButton_0million" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/million0" /> | |
<RadioButton | |
android:id="@+id/radioButton_3millions" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/million3" /> | |
<RadioButton | |
android:id="@+id/radioButton_17millions" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/million17" /> | |
<RadioButton | |
android:id="@+id/radioButton_36millions" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/million36" /> | |
<RadioButton | |
android:id="@+id/radioButton_48millions" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/million48" /> | |
<TextView | |
android:id="@+id/question3" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="@string/question3" | |
android:fontFamily="sans-serif" | |
android:textSize="18sp" | |
android:layout_marginTop="8dp" | |
android:layout_marginBottom="8dp" | |
android:textAlignment="viewStart" | |
android:layout_gravity="start" | |
android:textStyle="normal|bold"/> | |
<TextView | |
android:id="@+id/question3_text" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="16dp" | |
android:text="@string/question3_text" /> | |
<RadioButton | |
android:id="@+id/radioButton_Italy" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/italy" /> | |
<RadioButton | |
android:id="@+id/radioButton_Sweden" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/sweden" /> | |
<RadioButton | |
android:id="@+id/radioButton_Netherlands" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/netherlands" /> | |
<RadioButton | |
android:id="@+id/radioButton_Island" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/island" /> | |
<RadioButton | |
android:id="@+id/radioButton_Spain" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/spain" /> | |
<TextView | |
android:id="@+id/question4" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="@string/question4" | |
android:fontFamily="sans-serif" | |
android:textSize="18sp" | |
android:layout_marginTop="8dp" | |
android:layout_marginBottom="8dp" | |
android:textAlignment="viewStart" | |
android:layout_gravity="start" | |
android:textStyle="normal|bold"/> | |
<TextView | |
android:id="@+id/question4_text" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="16dp" | |
android:text="@string/question4_text" /> | |
<EditText | |
android:id="@+id/editText_percentage" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:ems="10" | |
android:hint="@string/percentage" | |
android:inputType="numberSigned" /> | |
<TextView | |
android:id="@+id/question5" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="@string/question5" | |
android:fontFamily="sans-serif" | |
android:layout_marginTop="8dp" | |
android:layout_marginBottom="8dp" | |
android:textSize="18sp" | |
android:textAlignment="viewStart" | |
android:layout_gravity="start" | |
android:textStyle="normal|bold"/> | |
<TextView | |
android:id="@+id/question5_text" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="16dp" | |
android:text="@string/question5_text" /> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:orientation="horizontal"> | |
<ImageView | |
android:id="@+id/imageView_Picasso1901" | |
android:layout_width="0dp" | |
android:layout_weight="1" | |
android:layout_height="60dp" | |
android:src="@drawable/picasso_woman_drinking_absinthe1901" | |
android:contentDescription="@string/imageView_WomanDrinkingAbsinthe1901" /> | |
<ImageView | |
android:id="@+id/imageView_Picasso1912" | |
android:layout_width="0dp" | |
android:layout_weight="1" | |
android:layout_height="60dp" | |
android:src="@drawable/picasso_bottle_of_pernod_and_glass1912" | |
android:contentDescription="@string/imageView_bottleOfPernodAndGlass1912" /> | |
<ImageView | |
android:id="@+id/imageView_Picasso1914" | |
android:layout_width="0dp" | |
android:layout_weight="1" | |
android:layout_height="60dp" | |
android:src="@drawable/picasso_absinthe_glass1914" | |
android:contentDescription="@string/imageView_absintheGlass1914" /> | |
</LinearLayout> | |
<EditText | |
android:id="@+id/editText_artist" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:ems="10" | |
android:hint="@string/artist" | |
android:inputType="text" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_horizontal" | |
android:id="@+id/evaluation"/> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="@string/evaluate" | |
android:layout_gravity="center_horizontal" | |
android:onClick="submitAnswers"/> | |
</LinearLayout> | |
</ScrollView> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment