From 9e5cda2974b2d7a90f6999249a47126e1a76b25d Mon Sep 17 00:00:00 2001 From: rhinemann Date: Sat, 9 Mar 2024 22:41:34 +0200 Subject: [PATCH] Added MBTI traching --- .../main/java/com/rhinemann/project/MBTI.java | 109 ++++++++++++++++++ .../com/rhinemann/project/MBTIResult.java | 85 ++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 app/src/main/java/com/rhinemann/project/MBTI.java create mode 100644 app/src/main/java/com/rhinemann/project/MBTIResult.java diff --git a/app/src/main/java/com/rhinemann/project/MBTI.java b/app/src/main/java/com/rhinemann/project/MBTI.java new file mode 100644 index 0000000..561c132 --- /dev/null +++ b/app/src/main/java/com/rhinemann/project/MBTI.java @@ -0,0 +1,109 @@ +package com.rhinemann.project; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.os.Bundle; +import android.widget.Button; +import android.widget.TextView; + +public class MBTI extends AppCompatActivity { + + Integer questionId; + TextView MBTIQuestion, MBTIAnswer; + String[] MBTIQuestions, MBTIAnswers; + String Result; + char[] ResultChar; + Button aButton, bButton, Home; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_mbti); + + questionId = 0; + + MBTIQuestion = findViewById(R.id.MBTI_Question); + MBTIAnswer = findViewById(R.id.MBTI_Answer); + + MBTIQuestions = getResources().getStringArray(R.array.MBTI_Questions); + MBTIAnswers = getResources().getStringArray(R.array.MBTI_Answers); + + aButton = findViewById(R.id.Button_A); + bButton = findViewById(R.id.Button_B); + + + Result = "MBTI"; + ResultChar = Result.toCharArray(); + + MBTIQuestion.setText(MBTIQuestions[questionId]); + MBTIAnswer.setText(MBTIAnswers[questionId]); + + aButton.setOnClickListener(v -> { + switch (questionId) { + case 0: + ResultChar[0] = 'E'; + break; + case 1: + + ResultChar[1] = 'S'; + break; + case 2: + ResultChar[2] = 'T'; + break; + case 3: + ResultChar[3] = 'J'; + break; + } + + Result = String.valueOf(ResultChar); + + if (questionId < 3) { + questionId++; + MBTIQuestion.setText(MBTIQuestions[questionId]); + MBTIAnswer.setText(MBTIAnswers[questionId]); + } else { MBTIResult(); } + }); + + bButton.setOnClickListener(v -> { + switch (questionId) { + case 0: + ResultChar[0] = 'I'; + break; + case 1: + + ResultChar[1] = 'N'; + break; + case 2: + ResultChar[2] = 'F'; + break; + case 3: + ResultChar[3] = 'P'; + break; + } + + Result = String.valueOf(ResultChar); + + if (questionId < 3) { + questionId++; + MBTIQuestion.setText(MBTIQuestions[questionId]); + MBTIAnswer.setText(MBTIAnswers[questionId]); + } else { MBTIResult(); } + }); + + Home = findViewById(R.id.home); + + Home.setOnClickListener(v -> { + Intent intent = new Intent(MBTI.this, HomeScreen.class); + startActivity(intent); + }); + + } + + public void MBTIResult(){ + Intent intent = new Intent(MBTI.this, MBTIResult.class); + intent.putExtra("Result", Result); + startActivity(intent); + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/rhinemann/project/MBTIResult.java b/app/src/main/java/com/rhinemann/project/MBTIResult.java new file mode 100644 index 0000000..0c7030f --- /dev/null +++ b/app/src/main/java/com/rhinemann/project/MBTIResult.java @@ -0,0 +1,85 @@ +package com.rhinemann.project; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.os.Bundle; +import android.widget.Button; +import android.widget.TextView; + +public class MBTIResult extends AppCompatActivity { + + TextView Result, Explanation; + String ResultText; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_mbtiresult); + + Result = findViewById(R.id.Result); + Explanation = findViewById(R.id.Explanation); + + ResultText = getIntent().getStringExtra("Result"); + + Result.setText(ResultText); + + switch (ResultText){ + case "ESTG": + Explanation.setText(R.string.ESTJ); + break; + case "ISTJ": + Explanation.setText(R.string.ISTJ); + break; + case "ESTP": + Explanation.setText(R.string.ESTP); + break; + case "ISTP": + Explanation.setText(R.string.ISTP); + break; + case "ENTJ": + Explanation.setText(R.string.ENTJ); + break; + case "INTJ": + Explanation.setText(R.string.INTJ); + break; + case "ENTP": + Explanation.setText(R.string.ENTP); + break; + case "INTP": + Explanation.setText(R.string.INTP); + break; + case "ESFJ": + Explanation.setText(R.string.ESFJ); + break; + case "ISFJ": + Explanation.setText(R.string.ISFJ); + break; + case "ESFP": + Explanation.setText(R.string.ESFP); + break; + case "ISFP": + Explanation.setText(R.string.ISFP); + break; + case "ENFJ": + Explanation.setText(R.string.ENFJ); + break; + case "INFJ": + Explanation.setText(R.string.INFJ); + break; + case "ENFP": + Explanation.setText(R.string.ENFP); + break; + case "INFP": + Explanation.setText(R.string.INFP); + break; + } + + Button Home = findViewById(R.id.home); + + Home.setOnClickListener(v -> { + Intent intent = new Intent(MBTIResult.this, HomeScreen.class); + startActivity(intent); + }); + } +} \ No newline at end of file