Permalink
Browse files

Redesigned verb forms as String array

Implemented futuro proximo and preterito perfecto
  • Loading branch information...
F1iX committed Oct 7, 2017
1 parent 2dea442 commit 9daf14eae4b85dcfc867b94a6cf7bd3c12f932a8

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,19 @@
package me.keppler.conjugator;

/**
* Created by felix on 07/10/17.
*/

public class GoingToFuture {
public static String[] get(String verb) {
// get conjugation of auxiliary verb ir
String[] forms = Present.get("ir");

// build combined going to future
for(int i = 0; i < forms.length; i++){
forms[i] = forms[i] + " a " + verb;
}

return forms;
}
}
@@ -3,6 +3,7 @@
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
@@ -54,62 +55,80 @@ public void afterTextChanged(final Editable s) {

void conjugate(){
String tense = "", example = "";
Conjugation forms;
String[] forms = {getString(R.string.s1)
, getString(R.string.s2)
, getString(R.string.s3)
, getString(R.string.p1)
, getString(R.string.p2)
, getString(R.string.p3)};

switch (tenseId) {
case 0:
tense = "Pretérito pluscuamperfecto";
example = "Yo había hablando = I had spoken";
forms = Present.get(verb);
if(verb.length() > 1) {
//forms = Pluperfect.get(verb);
}
break;
case 1:
tense = "Pretérito indefinido";
example = "Yo hablé = I spoke";
forms = Present.get(verb);
if(verb.length() > 1) {
//forms = PreteriteIndefinido.get(verb);
}
break;
case 2:
tense = "Pretérito imperfecto";
example = "Yo hablaba = I spoke";
forms = Present.get(verb);
if(verb.length() > 1) {
//forms = Imperfect.get(verb);
}
break;
case 3:
tense = "Pretérito perfecto";
example = "Yo he hablando = I have spoken";
forms = Present.get(verb);
if(verb.length() > 1) {
forms = PresentPerfect.get(verb);
}
break;
case 4:
tense = "Presente";
example = "Yo hablo = I speak";
forms = Present.get(verb);
if(verb.length() > 1) {
forms = Present.get(verb);
}
break;
case 5:
tense = "Futuro proximo";
example = "Yo voy a hablar = I am goint to speak";
forms = Present.get(verb);
example = "Yo voy a hablar = I am going to speak";
if(verb.length() > 1) {
forms = GoingToFuture.get(verb);
}
break;
case 6:
tense = "Futuro simple";
example = "Yo hablaré = I will speak";
forms = Present.get(verb);
if(verb.length() > 1) {
//forms = Future.get(verb);
}
break;
case 7:
tense = "Futuro perfecto";
example = "Yo habré hablando = I will have spoken";
forms = Present.get(verb);
break;
default:
forms = new Conjugation();
if(verb.length() > 1) {
//forms = FuturePerfect.get(verb);
}
break;
}

((TextView) findViewById(R.id.textViewTense)).setText(tense);
((TextView) findViewById(R.id.textViewExample)).setText(example);

((TextView) findViewById(R.id.textViewYo)).setText(forms.Yo);
((TextView) findViewById(R.id.textViewTu)).setText(forms.Tu);
((TextView) findViewById(R.id.textViewEl)).setText(forms.El);
((TextView) findViewById(R.id.textViewNosotros)).setText(forms.Nosotros);
((TextView) findViewById(R.id.textViewVosotros)).setText(forms.Vosotros);
((TextView) findViewById(R.id.textViewEllos)).setText(forms.Ellos);
((TextView) findViewById(R.id.textViewYo)).setText(forms[0]);
((TextView) findViewById(R.id.textViewTu)).setText(forms[1]);
((TextView) findViewById(R.id.textViewEl)).setText(forms[2]);
((TextView) findViewById(R.id.textViewNosotros)).setText(forms[3]);
((TextView) findViewById(R.id.textViewVosotros)).setText(forms[4]);
((TextView) findViewById(R.id.textViewEllos)).setText(forms[5]);
}
}
@@ -7,38 +7,73 @@
*/

public final class Present {
public static Conjugation get(String verb){
Conjugation forms = new Conjugation();
if(verb.length() < 2){
return forms; // no input, return default
} else if(verb.equals("ir")){
forms.Yo = "voy";
forms.Tu = "vas";
forms.El = "va";
forms.Nosotros = "vamos";
forms.Vosotros = "vais";
forms.Ellos = "van";
return forms;
}

public static String[] get(String verb){
String[] forms = new String[6];

// comer = eat
forms.Yo = verb.substring(0, verb.length()-2) + "o";
forms.Tu = verb.substring(0, verb.length()-2) + "es"; // differs for -ar
forms.El = verb.substring(0, verb.length()-2) + "e"; // differs for -ar
forms.Nosotros = verb.substring(0, verb.length()-2) + "emos"; // differs for -ir/-ar
forms.Vosotros = verb.substring(0, verb.length()-2) + "éis"; // differs for -ir/-ar
forms.Ellos = verb.substring(0, verb.length()-2) + "en"; // differs for -ar
forms[0] = verb.substring(0, verb.length()-2) + "o";
forms[1] = verb.substring(0, verb.length()-2) + "es"; // differs for -ar
forms[2] = verb.substring(0, verb.length()-2) + "e"; // differs for -ar
forms[3] = verb.substring(0, verb.length()-2) + "emos"; // differs for -ir/-ar
forms[4] = verb.substring(0, verb.length()-2) + "éis"; // differs for -ir/-ar
forms[5] = verb.substring(0, verb.length()-2) + "en"; // differs for -ar

if(verb.endsWith("ir")){ // asistir = attend
forms.Nosotros = verb.substring(0, verb.length()-2) + "imos";
forms.Vosotros = verb.substring(0, verb.length()-2) + "ís";
forms[3] = verb.substring(0, verb.length()-2) + "imos";
forms[4] = verb.substring(0, verb.length()-2) + "ís";
} else if(verb.endsWith("ar")){ // trabajar = work
forms.Tu = verb.substring(0, verb.length()-2) + "as";
forms.El = verb.substring(0, verb.length()-2) + "a";
forms.Nosotros = verb.substring(0, verb.length()-2) + "amos";
forms.Vosotros = verb.substring(0, verb.length()-2) + "áis";
forms.Ellos = verb.substring(0, verb.length()-2) + "an";
};
forms[1] = verb.substring(0, verb.length()-2) + "as";
forms[2] = verb.substring(0, verb.length()-2) + "a";
forms[3] = verb.substring(0, verb.length()-2) + "amos";
forms[4] = verb.substring(0, verb.length()-2) + "áis";
forms[5] = verb.substring(0, verb.length()-2) + "an";
}

if(verb.equals("ir")){
forms[0] = "voy";
forms[1] = "vas";
forms[2] = "va";
forms[3] = "vamos";
forms[4] = "vais";
forms[5] = "van";
} else if(verb.equals("dormir")){
forms[0] = "duermo";
forms[1] = "duermes";
forms[2] = "duerme";
forms[5] = "duermen";
} else if(verb.equals("haber")) {
forms[0] = "he";
forms[1] = "has";
forms[2] = "ha";
forms[3] = "habemos";
forms[5] = "han";
} else if(verb.equals("asir")){
forms[0] = "asgo";
} else if(verb.equals("caer")){
forms[0] = "caigo";
} else if(verb.equals("dar")){
forms[0] = "doy";
} else if(verb.equals("decir")){
forms[0] = "digo";
} else if(verb.equals("hacer")){
forms[0] = "hago";
} else if(verb.equals("poner")){
forms[0] = "pongo";
} else if(verb.equals("saber")){
forms[0] = "";
} else if(verb.equals("salir")){
forms[0] = "salgo";
} else if(verb.equals("tener")){
forms[0] = "tengo";
} else if(verb.equals("traer")){
forms[0] = "traigo";
} else if(verb.equals("valer")){
forms[0] = "valgo";
} else if(verb.equals("venir")){
forms[0] = "vengo";
} else if(verb.equals("ver")){
forms[0] = "veo";
}

return forms;
}
@@ -5,4 +5,56 @@
*/

public final class PresentPerfect {
public static String[] get(String verb) {
String pastParticiple;

if(verb.endsWith("ar")){ // trabajar -> trabajado
if(verb.matches(".*[aeiou]..")){ // add accent if a vowel precedes the ending (abstaer -> abstraído)
pastParticiple = verb.substring(0, verb.length() - 2) + "ádo";
} else {
pastParticiple = verb.substring(0, verb.length() - 2) + "ado";
}
} else { // comer -> comido as well as asistir -> asistido
if(verb.matches(".*[aeiou]{1}..")){ // add accent if a vowel precedes the ending (leer -> leído as well as abstaer -> abstraído)
pastParticiple = verb.substring(0, verb.length() - 2) + "ído";
} else {
pastParticiple = verb.substring(0, verb.length() - 2) + "ido";
}
}

if(verb.equals("abrir")){
pastParticiple = "abierto";
} else if(verb.equals("cubrir")){
pastParticiple = "cubierto";
} else if(verb.equals("decir")){
pastParticiple = "dicho";
} else if(verb.equals("escribir")){
pastParticiple = "escrito";
} else if(verb.equals("hacer")){
pastParticiple = "hecho";
} else if(verb.equals("imprimir")){
pastParticiple = "impreso";
} else if(verb.equals("morir")){
pastParticiple = "muerto";
} else if(verb.equals("poner")){
pastParticiple = "puesto";
} else if(verb.equals("resolver")){
pastParticiple = "resuelto";
} else if(verb.equals("romper")){
pastParticiple = "roto";
} else if(verb.equals("ver")){
pastParticiple = "visto";
} else if(verb.equals("volver")){
pastParticiple = "vuelto";
}
// get conjugation of auxiliary verb haber
String[] forms = Present.get("haber");

// build combined present perfect
for(int i = 0; i < forms.length; i++){
forms[i] = forms[i] + " " + pastParticiple;
}

return forms;
}
}

0 comments on commit 9daf14e

Please sign in to comment.