Assalamualaikum wr.wb.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package baharnoer.main;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Ramalan_02 extends MIDlet implements CommandListener
{
int hr, bl, th, 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 start = new Command("Start", Command.SCREEN, 1);
Command ramal = new Command("Ramal", Command.SCREEN, 1);
Command back = new Command("Back", Command.SCREEN, 1);
String hari, bulan, tahun, nm;
public Ramalan_02()
{
//Tampilan awal Aplikasi
StringItem si = new StringItem("welcome to Horoscope Application ", "Please, push Start button");
form1 = new Form("Ramalan");
form1.append(si);
form1.addCommand(start);
form1.addCommand(exit);
form1.setCommandListener(this);
// form untuk mengisi Data
form2 = new Form("Welcome to Horoscope Application");
nama = new TextField("Enter your name", "", 10, TextField.ANY);
form2.append(nama);
form1.addCommand(start);
form1.addCommand(exit);
form2.addCommand(back);
form2.addCommand(ramal);
form2.setCommandListener(this);
choice = new ChoiceGroup("Choice your birth of date", Choice.POPUP);
choice.append("1", null);
choice.append("2", null);
choice.append("3", null);
choice.append("4", null);
choice.append("5", null);
choice.append("6", null);
choice.append("7", null);
choice.append("8", null);
choice.append("9", 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);
choice.append("32", null);
form2.append(choice);
choice2 = new ChoiceGroup("Choice the Month ", 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("Choice the years", 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(" Ramalan anda Minggu ini :");
form3.setCommandListener(this);
}
public void startApp()
{
if (display == null)
{
display = Display.getDisplay(this);
}
display.setCurrent(form1);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c, Displayable d)
{
if (c == exit)
{
destroyApp(true);
notifyDestroyed();
}
if (c == start)
{
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(start);
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;
}
//Tanggal Lahir
for (int i = 0; i < 32; i++)
{
if (choice.isSelected(i))
{
hari = choice.getString(i);
hr = i + 1;
}
}
for (int i = 0; i < 12; i++)
{
if (choice2.isSelected(i))
{
bulan = choice2.getString(i);
bl = i + 1;
}
}
for (int i = 0; i < 20; i++)
{
if (choice3.isSelected(i))
{
tahun = choice3.getString(i);
th = i + 1981;
}
}
//jumlah nama + hari lahir untuk menentukan keuangan
a = (hr + jlhName) % 4;
//jumlah nama + hari lahir untuk menentukan asmara
b = (bl + jlhName) % 4;
//jumlah nama + hari lahir untuk menentukan karir
c = (th + jlhName) % 4;
kal = new StringItem("", "Your Name :" + nm + "\nBirht of Day :" + hari + " - " + bulan + " - " + tahun + "\n");
StringItem health = new StringItem("Healthy : ", "", StringItem.PLAIN);
StringItem finance = new StringItem("Finance : ", "", StringItem.PLAIN);
StringItem romance = new StringItem("Romance : ", "", StringItem.PLAIN);
StringItem career = new StringItem("Career : ", "", 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);
}
}
Below is the code of java mobile
to create horoscope application. So, this application will inform you the
condition of your self in weeks. Wether it’s about healthy, finance, career and romance. But remember, this not truely horoscope, this is just a task
of my java mobile class. Ok, The following is the code :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package baharnoer.main;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Ramalan_02 extends MIDlet implements CommandListener
{
int hr, bl, th, 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 start = new Command("Start", Command.SCREEN, 1);
Command ramal = new Command("Ramal", Command.SCREEN, 1);
Command back = new Command("Back", Command.SCREEN, 1);
String hari, bulan, tahun, nm;
public Ramalan_02()
{
//Tampilan awal Aplikasi
StringItem si = new StringItem("welcome to Horoscope Application ", "Please, push Start button");
form1 = new Form("Ramalan");
form1.append(si);
form1.addCommand(start);
form1.addCommand(exit);
form1.setCommandListener(this);
// form untuk mengisi Data
form2 = new Form("Welcome to Horoscope Application");
nama = new TextField("Enter your name", "", 10, TextField.ANY);
form2.append(nama);
form1.addCommand(start);
form1.addCommand(exit);
form2.addCommand(back);
form2.addCommand(ramal);
form2.setCommandListener(this);
choice = new ChoiceGroup("Choice your birth of date", Choice.POPUP);
choice.append("1", null);
choice.append("2", null);
choice.append("3", null);
choice.append("4", null);
choice.append("5", null);
choice.append("6", null);
choice.append("7", null);
choice.append("8", null);
choice.append("9", 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);
choice.append("32", null);
form2.append(choice);
choice2 = new ChoiceGroup("Choice the Month ", 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("Choice the years", 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(" Ramalan anda Minggu ini :");
form3.setCommandListener(this);
}
public void startApp()
{
if (display == null)
{
display = Display.getDisplay(this);
}
display.setCurrent(form1);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c, Displayable d)
{
if (c == exit)
{
destroyApp(true);
notifyDestroyed();
}
if (c == start)
{
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(start);
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;
}
//Tanggal Lahir
for (int i = 0; i < 32; i++)
{
if (choice.isSelected(i))
{
hari = choice.getString(i);
hr = i + 1;
}
}
for (int i = 0; i < 12; i++)
{
if (choice2.isSelected(i))
{
bulan = choice2.getString(i);
bl = i + 1;
}
}
for (int i = 0; i < 20; i++)
{
if (choice3.isSelected(i))
{
tahun = choice3.getString(i);
th = i + 1981;
}
}
//jumlah nama + hari lahir untuk menentukan keuangan
a = (hr + jlhName) % 4;
//jumlah nama + hari lahir untuk menentukan asmara
b = (bl + jlhName) % 4;
//jumlah nama + hari lahir untuk menentukan karir
c = (th + jlhName) % 4;
kal = new StringItem("", "Your Name :" + nm + "\nBirht of Day :" + hari + " - " + bulan + " - " + tahun + "\n");
StringItem health = new StringItem("Healthy : ", "", StringItem.PLAIN);
StringItem finance = new StringItem("Finance : ", "", StringItem.PLAIN);
StringItem romance = new StringItem("Romance : ", "", StringItem.PLAIN);
StringItem career = new StringItem("Career : ", "", 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);
}
}
Tidak ada komentar:
Posting Komentar