It is a program to find out your horoscope for this week is finance, romance, health and career.
package prayogo.minka.main;
//class java that needed to import program.
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author TOSHIBA
*/
//instantiation class
public class Tugas02 extends MIDlet implements CommandListener {
int hr, bln, thn, a, b, c, d;
Form form1, form2, form3, form4;
Display display;
StringItem kal;
TextField nama;
ChoiceGroup choice, choice2, choice3;
Command exit = new Command("Exit", Command.EXIT, 1);
Command mulai = new Command("Mulai", Command.SCREEN, 1);
Command ramal = new Command("Ramal", Command.SCREEN, 1);
Command back = new Command("Back", Command.SCREEN, 1);
String hari, bulan, tahun, nm;
//construcor.
public Tugas02() {
//first menu
super();
StringItem si = new StringItem("Aplikasi ramalan anda.","Tekan tombol mulai");
form1 = new Form("Ramalan");
form1.append(si);
form1.addCommand(mulai);
form1.addCommand(exit);
form1.setCommandListener(this);
//menu 2
form2 = new Form("Silahkan Lengkapi Data berikut..");
nama = new TextField("Masukkan Nama Anda", "", 25, TextField.ANY);
form2.append(nama);
form2.addCommand(back);
form2.addCommand(ramal);
form2.setCommandListener(this);
choice = new ChoiceGroup("Masukkan Tanggal Lahir Anda", Choice.POPUP);
choice.append("01", null);
choice.append("02", null);
choice.append("03", null);
choice.append("04", null);
choice.append("05", null);
choice.append("06", null);
choice.append("07", null);
choice.append("08", null);
choice.append("09", null);
choice.append("10", null);
choice.append("11", null);
choice.append("12", null);
choice.append("13", null);
choice.append("14", null);
choice.append("15", null);
choice.append("16", null);
choice.append("17", null);
choice.append("18", null);
choice.append("19", null);
choice.append("20", null);
choice.append("21", null);
choice.append("22", null);
choice.append("23", null);
choice.append("24", null);
choice.append("25", null);
choice.append("26", null);
choice.append("27", null);
choice.append("28", null);
choice.append("29", null);
choice.append("30", null);
choice.append("31", null);
form2.append(choice);
choice2 = new ChoiceGroup("Lahir Anda di Bulan", Choice.POPUP);
choice2.append("Januari", null);
choice2.append("Februari", null);
choice2.append("Maret", null);
choice2.append("April", null);
choice2.append("Mei", null);
choice2.append("Juni", null);
choice2.append("July", null);
choice2.append("Agustus", null);
choice2.append("September", null);
choice2.append("Oktober", null);
choice2.append("November", null);
choice2.append("Desember", null);
form2.append(choice2);
choice3 = new ChoiceGroup("Masukkan Tahun Lahir Anda", Choice.POPUP);
choice3.append("1980", null);
choice3.append("1981", null);
choice3.append("1982", null);
choice3.append("1983", null);
choice3.append("1984", null);
choice3.append("1985", null);
choice3.append("1986", null);
choice3.append("1987", null);
choice3.append("1988", null);
choice3.append("1989", null);
choice3.append("1990", null);
choice3.append("1991", null);
choice3.append("1992", null);
choice3.append("1993", null);
choice3.append("1994", null);
choice3.append("1995", null);
choice3.append("1996", null);
choice3.append("1997", null);
choice3.append("1998", null);
choice3.append("2000", null);
form2.append(choice3);
form3 = new Form("Kalkulasi Ramalan");
form3.setCommandListener(this);
}
// running application and it's show the form
public void startApp() {
if (display == null) {
display = Display.getDisplay(this);
}
display.setCurrent(form1);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
//if choose exitCommand, destroyApp will be execute.
//and if it choose ramal, hitung() function will be execute.
public void commandAction(Command c, Displayable d) {
if (c == exit) {
destroyApp(true);
notifyDestroyed();
}
if (c == mulai) {
display.setCurrent(form2);
}
if (c == back) {
display.setCurrent(form1);
}
if (c == ramal) {
ramal();
display.setCurrent(form3);
}
}
private void alertnya(String title, String msg) {
Alert alert = new Alert(title, msg, null, AlertType.INFO);
alert.addCommand(mulai);
alert.setTimeout(alert.FOREVER);
alert.setCommandListener(this);
display.setCurrent(alert);
}
public void ramal() {
String[] kesehatan = {
"Sakit", "Kurang Sehat", "Periksa ke Dokter", "Mantap"
};
String[] keuangan = {
"Minus", "Cukup", "Baik", "Berlebih"
};
String[] asmara = {
"Galau", "PDKT", "Berbunga", "Romantis"
};
String[] karir = {
"Bermasalah", "Tersendat - sendat", "Normal", "Lancar"
};
nm = nama.getString();
String name = nama.getString();
char[] letter = name.toCharArray();
int l = letter.length;
int[] pose;
pose = new int[l];
int jlhName = 0;
for (int i = 0; i < l; i++) {
pose[i] = ((int) letter[i]) - 96;
jlhName = jlhName + pose[i];
d = jlhName % 4;
}
//For choice date.
for (int i = 0; i < 31; i++) {
if (choice.isSelected(i)) {
hari = choice.getString(i);
hr = i + 1;
}
}
//for choice month.
for (int i = 0; i < 12; i++) {
if (choice2.isSelected(i)) {
bulan = choice2.getString(i);
bln = i + 1;
}
}
//for choice years.
for (int i = 0; i < 20; i++) {
if (choice3.isSelected(i)) {
tahun = choice3.getString(i);
thn = i + 1981;
}
}
//The number of name + day of birth to determine the financial.
a = (hr + jlhName) % 4;
//The number of name + day of birth to determine the romance.
b = (bln + jlhName) % 4;
//The number of name + day of birth to determine the career.
c = (thn + jlhName) % 4;
kal = new StringItem("", "Nama anda :" + nm + "\nHari Lahir :" + hari + "\nBulan Lahir
:" + bulan + "\nTahun Lahir :" + tahun + "\n");
StringItem health = new StringItem("Kesehatan Anda : ", "", StringItem.PLAIN);
StringItem finance = new StringItem("Keuangan Anda : ", "", StringItem.PLAIN);
StringItem romance = new StringItem("Asmara Anda : ", "", StringItem.PLAIN);
StringItem career = new StringItem("Karir Anda : ", "", StringItem.PLAIN);
if (d == 0) {
health.setText(kesehatan[0]);
} else if (d == 1) {
health.setText(kesehatan[1]);
} else if (d == 2) {
health.setText(kesehatan[2]);
} else if (d == 3) {
health.setText(kesehatan[3]);
}
if (a == 0) {
finance.setText(keuangan[0]);
} else if (a == 1) {
finance.setText(keuangan[1]);
} else if (a == 2) {
finance.setText(keuangan[2]);
} else if (a == 3) {
finance.setText(keuangan[3]);
}
if (b == 0) {
romance.setText(asmara[0]);
} else if (b == 1) {
romance.setText(asmara[1]);
} else if (b == 2) {
romance.setText(asmara[2]);
} else if (b == 3) {
romance.setText(asmara[3]);
}
if (c == 0) {
career.setText(karir[0]);
} else if (c == 1) {
career.setText(karir[1]);
} else if (c == 2) {
career.setText(karir[2]);
} else if (c == 3) {
career.setText(karir[3]);
}
form3.append(kal);
form3.append(health);
form3.append(finance);
form3.append(romance);
form3.append(career);
form3.addCommand(exit);
}
}
Picture 1
Start the application and clik mulai
Picture 2
Insert your name, choose day of birt, month of birt and years of birt
and then clik ramal
Picture 3
This form horoscope for insert your date



Tidak ada komentar:
Posting Komentar