Added MBTI traching

This commit is contained in:
rhinemann 2024-03-09 22:41:34 +02:00
parent 79194f6c74
commit 9e5cda2974
2 changed files with 194 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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);
});
}
}