بسم الله الرحمن الرحيم
اخواني اخواتي السلام عليكم ورحمة الله وبركاته
حقيقة واجهت صعوبه في تطوير لعبة مسابقة من سيربح المليون وخصوصا تخزين سته من الاسئله مع اربع اجابات واجابه صحيحه بحيث عند فتح الاعب للعبه تكون الاسئله جاهزه ويستطيع اللعب مباشره وبعد ذلك ان كان لديه صلاحية الادمن فله ان يضيف او يحذف او يعدل اي سؤال شريطة ان يتم تخزينهم قبل الخروج من اللعبه
لا اريد ان اطيل عليكم ولكنني سأضع السؤال حيث انه باللغه الانجليزيه وفي طياته التفاصيل كامله
You are required to develop a game ‘Millionaire’ for use on a mobile phone.
Stage A
The application consists of a menu which gives the option of ‘play’ for playing the game (for the player) or ‘Admin’ for adding the records (for the developer). Create an initial screen with two commands ‘Play’ or ‘Admin’.If the user chooses to play then the game is played in the normal way. If the user chooses ‘Admin’ then a screen is presented where the user is prompted for a password. Add a command to this screen “select” If the password ‘1234’ is entered then pressing the select command gives the user access to the admin function (“add” in the case of stage A). If an incorrect password is entered then the user is directed back to the initial screen. The‘Admin’ part consists of adding a question (shown using a screen command “add”) which when selected adds a question followed by four answers and the correct answer (either A,B,C or D) to a datastore which can be retrieved every time the application is run. The play part consists of the application retrieving the question followed by the four possible answers, from which the player can choose one answer. A message (maybe a ticker) provides feedback as to whether the answer has been answered correctly. After a player has chosen an answer and received feedback he/she is not allowed to change the selection choice. The software will then display the next question plus four answers and so on. You should enter about 6 questions plus answers.Your program should display the questions when you run it and you should not have to manually enter the questions when you demonstrate the program. At the end of the game the software displays the message ‘Game Over’ and displays the number of questions answered correctly plus the total number of questions.
لقد تعثرت في حفظ الاسئله واجوبتها ارجوا ان احصل منكم على مساعده او اضافه الى الكود الذي قد شرعت في كتابته وجزاكم الله الف خير
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.*;
import javax.microedition.media.*;
import java.io.*;
/**
*
*/
public class MillionGame extends MIDlet implements CommandListener {
private Display display; // Reference to Display object for this MIDlet
private Form form; // Main form of the game
private Command exit; // Exit the Game
private Command play; // Start Playing game
private Command admin; // Go to admin Menu
private Command cancel; // Go back to home screen
private Command login; // Login in the admin Menu
private Command start; // Start Game Mode
private Command addQ;
private Command insert;
private Command next;
private Command finish;
private TextField q,a,b,c,d,ans;
private Command update;
private Command delete;
private Command view;
private StringItem question;
private ChoiceGroup answers;
private ImageItem imageItem;
private TextField passwrd; // used to enter password
private Image img1, img2, img3; // to append images
// Get the Display to start Midlet
public MillionGame() {
display = Display.getDisplay(this);
// Create the Form, add Commands, listen for events
}
public void startApp() {
mainMenu();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
public void mainMenu() {
form = new Form("Millionaire Game");
exit = new Command("Exit", Command.EXIT, 1);
play = new Command("Play", Command.SCREEN, 2);
admin = new Command("Admin Menu", Command.SCREEN, 3);
form.append("Select Play or Admin from menu.");
form.addCommand(exit);
form.addCommand(play);
form.addCommand(admin);
form.setCommandListener(this);
display.setCurrent(form);
}
//Listen for Command Events
public void commandAction(Command cm, Displayable s) {
if (cm == exit) {
destroyApp(false);
notifyDestroyed();
} else if (cm == play) {
gameMode();
} else if (cm == admin) {
loginUser();
} else if (cm == login) {
allowUser(passwrd.getString());
} else if (cm == cancel){
mainMenu();
} else if (cm == addQ) {
addQuestion();
}
}
// Authenticate for Admin Mode
public void loginUser() {
form = new Form("Admin Menu Login");
cancel = new Command("Cancel", Command.CANCEL, 2);
login = new Command("Login", Command.OK, 2);
form.addCommand(cancel);
form.addCommand(login);
form.setCommandListener(this);
//form.append("Enter password");
form.append(passwrd = new TextField("Enter password", "", 4, TextField.PASSWORD));
display.setCurrent(form);
}
public void gameMode() {
form = new Form("you're playing Millionaire");
question = new StringItem("Question: ","What is the capital city of Malaysia?");
answers = new ChoiceGroup("Select to move to the next Q",Choice.EXCLUSIVE);
answers.append("Kuala Lumpure",null);
answers.append("Sana'a",null);
answers.append("Parise",null);
answers.append("Berlin",null);
start = new Command("Select", Command.SCREEN, 1);
cancel = new Command("Cancel", Command.CANCEL, 2);
form.addCommand(start);
form.addCommand(cancel);
form.append(question);
form.append(answers);
form.setCommandListener(this);
display.setCurrent(form);
}
public void allowUser(String password) {
if (password.equals("1234")) {
adminMenu();
} else {
tryAgain();
}
}
public void adminMenu() {
form = new Form("Weclome to Admin Menu");
cancel = new Command("Game Menu", Command.CANCEL, 1);
addQ = new Command("Add", Command.SCREEN, 2);
update = new Command("Update", Command.SCREEN, 3);
delete = new Command("Delete", Command.SCREEN, 4);
view = new Command("View", Command.SCREEN, 5);
form.append("- Select from menu to Add, Update or Delete Questions.\n");
form.append("- Select the View option to observe the changes at anytime.");
form.addCommand(cancel);
form.addCommand(addQ);
form.addCommand(update);
form.addCommand(delete);
form.addCommand(view);
form.setCommandListener(this);
display.setCurrent(form);
}
public void tryAgain()
{
Alert error = new Alert("Incorrect Login", "Please try again", null, AlertType.ERROR);
error.setTimeout(3000);
passwrd.setString("");
display.setCurrent(error, form);
//mainMenu();
}
// Display the Add a Question Screen
public void addQuestion() {
form = new Form("Add Quesion");
insert = new Command("Insert", Command.SCREEN, 1);
next = new Command("Next", Command.SCREEN, 2);
finish = new Command("Finish", Command.SCREEN, 3);
form.addCommand(insert);
form.addCommand(finish);
form.addCommand(next);
form.setCommandListener(this);
form.append(q = new TextField("Q:", "", 60, TextField.ANY));
form.append(a = new TextField("A.", "", 12, TextField.ANY));
form.append(b = new TextField("B.", "", 12, TextField.ANY));
form.append(c = new TextField("C.", "", 12, TextField.ANY));
form.append(d = new TextField("D.", "", 12, TextField.ANY));
form.append(ans = new TextField("Answer:", "", 12, TextField.ANY));
display.setCurrent(form);
}
}