Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

wanttobeamillionaire

Posted on 2001-06-18
8
327 Views
Last Modified: 2008-03-10
Write an application to make entries for the "Who wants to be a Millionaire?" game. The specification for the entry frame is given as a prototype, see Figure 1. The entry frame has three main components, the "Welcome" label, the question/answers panel and the buttons panel at the bottom.

 
Figure 1. Entry Frame for the questions.

The layout of the frame is defined within the attached java file. The functionality of each button is as follows:
Upon completion of an entry,
? If the <Add> button is pressed, then the data from the text fields and the radio button set is collected and used to create a new Question instance, then this question is added to the list(Vector) of questions. The fields are cleared.
? If the <Save> button is pressed, then all the data that was gathered within the list of questions(Vector) is written to a file. The fields are cleared. The list of questions are initialized to an empty list.
? If the <Read> button is pressed, then the list of questions is read from the file and used to set the data of the Vector.
The above scenario assumes the order of operation as <Add>?, <Save>, <Read>, <Next>?. If the user presses the <Save> before any <Add> happens, an empty Vector will be written to the file.

Project Part-I requires you to populate the saveQuestions() and readQuestions() methods.
Project Part-II requires you to add a <Next> button to the button panel with the following functionality:
? After a <Read> happens, if the <Next> button is pressed, then the next question in the Vector is displayed. You need to keep an index in order to remember the current position.
? Bonus: The <Next> button gets disabled when there are no elements in the Vector or if the end of Vector is reached.

The project should include:
 i. Error checking. Currently if there is no selection for the entry, an exception will be thrown. (Hint: You can place error checking for the missing elements in the constructor of the Question or elsewhere.)Exceptions handling (file io).
 ii. Full documentation using javadoc comments and the html files.
 iii. You can populate any of the components with explanatory text and modify the attributes.
 iv. No development environment tools are allowed. I do recognize the code generated by the IDE tools.
0
Comment
Question by:lawmer
  • 5
  • 2
8 Comments
 
LVL 15

Expert Comment

by:ozymandias
ID: 6205734
Are you asking us to do your homework ?
0
 

Author Comment

by:lawmer
ID: 6206004
No I am not I just have never ever have taken a programming course and I was thrust into a graduate level java course in which had several prerequesits. A mistake from our advissor who was suppose to assign a programming appreciation course. On to top of that the professor is out of the country for questions.

Could you just get me in the ballpark this is way over my head.
0
 

Author Comment

by:lawmer
ID: 6206014
I have all of the templates I just need to know how to populate read and save
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 15

Accepted Solution

by:
ozymandias earned 75 total points
ID: 6207116
. Saving the vector to a file and restoring it from a file requires a technique called serialization. This is where an object is written (int this case to a file).

Look in the Java API documentation at the interface called Serializable.

Basically you create an ObjectOutputStream pointing to a file :

  File f = new File(your_file_name_goes_here);
  ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f));

Then you call the writeObject method of the ObjectOutputStream and pass it the Vector :

  oos.writeObject(vector);

Getting the vector back from the file is thesame kind of thing but in reverse.

Here are a couple of examples :

SerialVector1 creates a vector of the arguments you pass it and serializes it to a file called serialvector.dat. SerialVector2 gets the vector back and prints out its contents.

0
 
LVL 15

Expert Comment

by:ozymandias
ID: 6207117
import java.util.Vector;
import java.io.*;

public class SerialVector1{

     public static void main(String args[]){
          try{
               Vector v = new Vector();
               for (int i = 0; i < args.length; i++){
                    v.add(args[i]);
               }
               File f = new File("serialvector.dat");
               ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f));
               oos.writeObject(v);
          }catch(Exception e){
               e.printStackTrace(System.out);
          }
     }
}
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 6207119
import java.util.Vector;
import java.io.*;

public class SerialVector2{

     public static void main(String args[]){
          try{
               File f = new File("serialvector.dat");
               ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f));
               Vector v = (Vector) ois.readObject();
               for (int i = 0; i < v.size(); i++){
                    System.out.println(((String)v.elementAt(i)));
               }
          }catch(Exception e){
               e.printStackTrace(System.out);
          }
     }
}
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 6207137
Complie the above files and then run them like this :

  java SerialVector1 hello goodbye whatever etc

then

  java SerialVector2

The output from SerialVector2 should be :

  hello
  goodbye
  whatever
  etc

Cheers.


0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 8950803


No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


--  points to ozymandias


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question