Replace text multiple times

Tag: text , replace Author: kkbbl0 Date: 2013-09-27

I am trying to display one word and then replace the word with another, and repeat this four-five times, Please let me know if you can help. I am new to Processing so I apologize if my code is incorrectly formatted.

String happy = "Happy";
String displayed ="";



int interval = 2000; // 2s
int a = 4000;

int time;

PFont font;


void setup() 
{
size(800, 800);
font = createFont("arial", 26);
background(0);
displayed = happy;



time = millis();
textFont(font);
fill(255);
}

void draw() {
background(0);



text(displayed, width/2 - textWidth(displayed)/2, height/2);
if (millis() - time > interval) {
displayed = "Sad";
time  = millis();
}
if (millis() - time > interval*2) {
displayed = "Angry";
time  = millis();
}
}