peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Lets make bargain.
You give me code what you have plus maybe how it should approached and I will try to improve it with you.
Do we have deal?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

It is not such a difficult task.
Create a constructor something like this

Test(String question, String answerA, String answerB, String answerC, String correctAnswer)

Fill in data and put it in Array/ArrayList/Vector (something you familiar with).
Your frame view can be split into three panels CountPanel (showing current position or question taken in the test), QuestionPanel (build of label with question and check boxes in CheckboxGroup)and ButtonPanel (with button) on the first view you will show first data set for question one.
Now you have come up with simple logic that will on button press swap data in in the label and checkbox group of your QuestionPanel with new set, plus it will increment the count

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Here is "little dirty" solution

import java.util.*;
import javax.swing.JOptionPane;
public class RandomNumber
{	
	public static void main(String[] args) 
	{
	
		String output="";
		int[] arrayRan=new int[6];
		int rand;
		for(int i=0;i<arrayRan.length;i++)
		{
			do //execute following line
			{
				rand =(int)(Math.random()*48)+1;
			}while(doesExists(rand, arrayRan, i)); //while return is true
			arrayRan[i] = rand;
		}
		Arrays.sort(arrayRan);
		for(int i=0;i<arrayRan.length;i++)
		{
			System.out.println(arrayRan[i]);
		}
				
	}
	
	private static boolean doesExists(int rand, int[] arr, int i)
	{
		if( i != 0)
		{
			for(int j = 0; j < i; j++)
			{
				if(rand == arr[j])
					return true;	// number already in the array
			}			
		}
		return false;
	}
}

If you have any questions just ask

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

There is no install, you just upload CSS file to your web server and tell the HTML/XHTML/PHP or what ever format you gone use that it should use this layout, plus in the document you tell tags which settings to use. For example <table class="bordless"....> . If image is used as background or in some decoration, find it CSS and change the path of the image for the path to your image

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Separate tables, it will make your life easier for the tracking purposes, also if you really want you can extend this beyond two tables...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I expect that argument count is related to Member array box and is holding the actual size of the array ( correct me if I'm wrong)
Then you try to read file and store retrieved data in the box array.
You try to insert first set of data into array position of count.
However as count hold the array size the variable already exceeds array boundaries as Array.size() returns number of elements (lets say 20), however last element position is actually equal to count-1 ( that will be 19 as arrays starts from zero unlike vector for example). This kick off your NullPointerException.

If your method is supposed to read a file and return retrieved data you would be better of with method that will return the array then try to locally fill in and then re-use it.

Unfortunately you may not always know amount of data to be read so you should use something more "dynamic" like ArrayList or Vector. I re-do you read method little so now instead of void you get some return therefore to call it do as follows

ArrayList<Member> boxReturn = read();

and here is update read method

public static ArrayList<Memeber> read()
	{
		ArrayList<Member> box = new ArrayList<Member>();
		Scanner reader = null;
		
		try
		{	
			reader = new Scanner(new FileReader("database.txt"));
			
			int id; 
			String type, fn, ln, ph;
			Double fee;
			
			while(reader.hasNextLine())
			{
				id= reader.nextInt();
				type= reader.next();
				fn= reader.next();
				ln= reader.next();
				ph= reader.next();
				fee= reader.nextDouble();
				
				System.out.println(count);
				box.add( new Member(id, type, fn, …
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

General resource The Java EE 5 Tutorial, Beginning and Intermediate-Level Servlet, JSP, and JDBC Tutorials plus I enjoyed Java How to Program, 6th edition from Deitel

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Servlets are essential in Java web development so you will not escape them if you considering job related to Java development. Sooner or later you will have to face your enemy and I would say do it now, because now you will learn easier then later to try put a side your previous bad habits.
If you can explain where you having difficulties with servlet implementation we may be able to help you.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Have look at this, it is related to JFileChooser but the file filters option can be easily used in servlet

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You should create some sort of view (in JSP) where user can browse the whole web folder structure something like this

with some buttons on the bottom (I cut that off image would be to big)
Then let the user mark the file/folders for deleting. User hit the delete button, JSP send names of selected files for deletion together with current folder level to servlet, servlet does his deleting job and returns updated view in JSP of current folder level with some notifications message such as "file deleted", "unable to delete"

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
public static boolean question(){
	int a= (int)(Math.random()*(10)+1);
	int b=(int)(Math.random()*(10)+1);
	char op;
	int ka;
	String kidsanswer;
	op = get_choice();
	kidsanswer= JOptionPane.showInputDialog(a+op+b+"=?");
	ka= Integer.parseInt( kidsanswer);
	int compuanswer;
	switch (op){
			
		case '+': compuanswer= a+b;
		boolean answer;
		if (compuanswer==ka){
			JOptionPane.showMessageDialog(null, "Well Done!");
			return true;}
		else if (compuanswer!=ka){
			JOptionPane.showMessageDialog(null, "Wrong, sucker!" +
			"The correct answer is:" + compuanswer);
			return false;} 
		break;
			
		case '-': compuanswer= a-b;
		if (compuanswer==ka){
			JOptionPane.showMessageDialog(null, "Well Done!");
			return true;}
		else if (compuanswer!=ka){
			JOptionPane.showMessageDialog(null, "Wrong, sucker!" +
				"The correct answer is:" + compuanswer);
			return false;} 
		break;
			
		case '*':
		compuanswer= a*b;
		if (compuanswer==ka){
			JOptionPane.showMessageDialog(null, "Well Done!");
			return true;}
		else if (compuanswer!=ka){
			JOptionPane.showMessageDialog(null, "Wrong, sucker!" +
				"The correct answer is:" + compuanswer);
			return false; } 
		break;
			
		case '/':
		compuanswer= a/b;
		if (compuanswer==ka){
			JOptionPane.showMessageDialog(null, "Well Done!");
			return true;}
		else if (compuanswer!=ka){
			JOptionPane.showMessageDialog(null, "Wrong, sucker!" +
				"The correct answer is:" + compuanswer);
			return false;} 
		break;
			
		default:
		break;
	}
	return false;
}

Jasimp already gave you answer which you happily overseen, you missing return statement in case user insert something else then "+ - * /", plus I took liberty to move default statement to place where it belongs. My only hope is that you not gone submit this program anywhere as that offensive return statement in case of wrong answer could get you proper smack in your face...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

This post is nearly 2 year old!
While we like to see a solution to the problem, we rather prefer solution to be explained in the post and not to be redirected to members personal website. So please do not post links to your site and rather use copy&paste in the future.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Do as per may previous post.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

There is a second possibility that suvirj uses a book that from chapter section to another chapter section change code little and he would like to keep original code, but on other hand he also want to apply changes as suggested in new exercises.
In this case create new project as the book ask you, then in Windows Explorer go to location of your original/previous project, copy files from src (source) folder to src folder of your newly created project directory.
In doing so you will have copy of previous exercise and you can continue with new one.

PS: You just posted reply, but this still does not make sense. Can you clarify issue with consideration of what I wrote above?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

> Because number can be greater or smaller then other number,
> however you can not apply same logic to characters

Yes, you can, because characters form a part of numeric data type. There are only two primitive types in Java: boolean and numeric.

Directly comparing characters can be troublesome if your application is aimed at providing internationalization in which case some sort of unicode sensitive comparison needs to be provided.

One always learn something new, if he listen...
Thanx

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Let me help you , already first entry from ryangoodman solves your issue

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Because number can be greater or smaller then other number, however you can not apply same logic to characters ( I think Perl is exception in this). As I said before you should use equal() or any of compareTo() when you work with characters or strings

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

your while loop for seats doesn't work properly you should not use mathematical comparison on characters or strings. You can use either every present equals() method or compareTo().
I used equals and little redo row section

//All the code till line 177
        while(!rowChecking(columnNo))
        {
            System.out.print("Enter seat letter (A - F): ");
            columnNo = console.next().charAt(0);
            System.out.println();
        }
}

private static boolean rowChecking(char columnNo)
{
    Character[] rowLett = {'A','B','C','D','E','F'};
    for(int i = 0; i < rowLett.length; i++)
    {
        if(rowLett[i].equals(columnNo))
            return true;
    }
    return false;
}

PS: You can add lower case character into array in rowChecking method so user is not limited only to upper case, other posibility would be using some ignore case method

PS2: Once your run it with this addition it will kick of with another error at sPlan[rowNum - 1][(int)columnPos - 65] = 'X'; in assignFirstClassSeat() method. This is because both values are zero and you try to subtract from them Array out of bondaries

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Try to apply BevelBorder and SoftBevelBorder to buttons, this should give them some sort of 3d look

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You been on right track, but you just forgot to set counter after each while loop back to zero. Because of that capital letters and digit is never checked.
Also you may consider something like this

import javax.swing.*;

public class PasswordCheck
{	
	public static void main(String[] args)
	{
		String input;  
		
		input = JOptionPane.showInputDialog("Please enter password");
		
		// Validate user's input
		if (isValid(input))
		{
			JOptionPane.showMessageDialog(null, "Your password is valid!");
		}
		else
		{
			JOptionPane.showMessageDialog(null, "Your password is invalid " +
					"valid password criteria.");
		}
		System.exit(0);
	}
		
		/**
			The isValid method determines password validity.
			@param passWord The String to test.
			@return true if valid, or else false.
		*/
		
	private static boolean isValid(String pw)
	{
		if(checkLength(pw) && lowCaseCheck(pw) && upCaseCheck(pw) && digCheck(pw))
		{
			return true;
		}
		return false;
	}
	
	private static boolean checkLength(String psw)
	{
		if (psw.length() == 5){return true;}
		return false;
	}
	
	private static boolean lowCaseCheck(String psw)
	{
		for(int i = 0; i < psw.length(); i++)
		{
			if(Character.isLowerCase(psw.charAt(i)))
			{
				return true;
			}
		}
		return false;
	}
	
	private static boolean upCaseCheck(String psw)
	{
		for(int i = 0; i < psw.length(); i++)
		{
			if(Character.isUpperCase(psw.charAt(i)))
			{
				return true;
			}
		}
		return false;
	}
	
	private static boolean digCheck(String psw)
	{
		for(int i = 0; i < psw.length(); i++)
		{
			if(Character.isDigit(psw.charAt(i)))
			{
				return true;
			}
		}
		return false;
	}
}
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

That is what I was trying to say stephen84s , thank you.
phallett - I absolutely agree with you that you should choose most suitable IDE for your self once in industry or hobbies projects, however I will strongly disagree if you say to do this in early stage of learning Java.
Example, while doing my first degree and even now on my second numerous classmates in many cases do not know what they actually coding. They will come with all this wild ideas "I want my application looks like this or that and it will have such and such functionality", however they horribly fail as they not capable deliver what they promise, in many cases not even barre minimum. They struggle with the code because many of them do not know how to pass arguments between methods, not mentioning passing between classes and at least 70% of them deliver their assignments in single class.
How is this possible?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If you have something to say on topic as per PhiberOptik request please do so, however personal attacks will not be tolerated.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Suggesting to beginner to use a tool because of easier design is not worth as they may not learn the background process involved. Same thing as somebody says "I want to learn html" and then somebody else jumps in "Use Dreamweaver, it is the best tool". Next post you see from the first poster will be "I did this in DW and it is not working! What is wrong?"

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Of course!
Take for example simple search process to check how many people earn between 20k-25k. With file approach you need to read the file, temporary store it somewhere, close the file, you need to iterate trough to find results and then do what ever you want. Where in case of database you just write a query and check for results from DB.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Expand your world stephen84s, IntelliJ IDEA RULES!

Seriously now, I never used BlueJ, I did not become friend with Eclipse, but in my early days I used free version of JCreator, later on moved to NetBeans and since last year when I persuaded one of university teachers to get student licence I'm using IntelliJ IDEA.

If I may suggest, I will say go on with JCreator to learn basics and later try any of IntelliJ IDEA, NetBeans or Eclipse to find out which suites you best

PS: In responds to this post

I usually use Eclipse, but switch over to Netbeans when I do any sort of GUI.

To suggest using NetBeans as quick solution for GUI design is bad. If you do not know how to build GUI from scratch without GUI designer and drag&drop approach you know nothing

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

So you able to retrieve your data now?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If it is web project you should just simply drop the JAR into WEB_PROJECT/WEB-INF/lib directory and IDE should automatically pick-up the change.
In the case that driver is not recognised or you working on different type of project, GUI/mobile or any other project, right click on the project, select PROPERTIES, in the pop-up window in CATEGORIES (left side listing) select Libraries, on the right press Add JAR/Folder and navigate to place where is the driver.
Otherwise you may try to follow this obscure NetBeans tutorial

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Error message is self-explanatory, you missing JDBC driver Connector/J or if you have it you did not added to your project CLASSPATH

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

This post was originally created in 2005, time to time somebody bump it requesting requesting whole code or help in coding it.
You know what? You better of to create new post, state what you looking for, what you did and wait till somebody will reply. Posting in old posts without solution is dead-end scenario.
Think about it...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

frames is something w3c would really like to forget about, they did good job some 5-7 years ago, but now are obsolete...
Checking html 5 this concept is nearly abandoned and only remains of previous frames glory is only iframe and something about framesets http://dev.w3.org/html5/spec/Overview.html

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Silly question, end of line System.Data.SqlClient.SqlException what you got colon ":" or semicolon ";" ?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Ah bugger, seems like I'm little rusty on basic file I/O. Forget append.
In your case you need to only use different FileWritter constructor FileWriter(File file, boolean append)

writer = new BufferedWriter(new FileWriter(file + ".txt", true));
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If you want to use same file without loosing original content then you need to use append() method inherited from Writer class

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

What about binary calculations ;)
010
AND
010
is
100

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Sorry for the first one I misread your request, but did not get far off.
As I do not know exactly your storing procedure of Point coordinates I will guess and use little dirty coding

for(i = 0; i < vector.size()-1; i++)
{
    Point a = (Point) vector.get(i);
    Point b = (Point) vector.get(i+1);
    if(a.x < b.x && a.y < b.y)
    {
        System.out.println("Got my coordinates");
        i++; // need to move one extra position so loop doesn't use "b" Point
    }
    else
    {
        System.out.println("A point has bigger values then B");
        //for loop moves "b" values to "a" and be get new set
    }
}
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Why not have class like this

public class Points
{
	private int xTopLeft;
	private int yTopLeft;
	private int xBottRight;
	private int yBottRight;
	
	public Points(){}
	
	public Points(int a, int b, int c, int d)
	{
		setXTopLeft(a);
		setYTopLeft(b);
		setXBottRight(c);
		setYBottRight(d);
	}
	
	private void setXTopLeft(int i){xTopLeft = i;}
	public int getXTopLeft(){return xTopLeft;}
	
	private void setYTopLeft(int i){yTopLeft = i;}
	public int getYTopLeft() { return yTopLeft;}
	
	private void setXBottRight(int i) {xBottRight = i;}
	public int getXBottRight(){return xBottRight;}
	
	private void setYBottRight(int i) {yBottRight = i;}
	public int getYBottRight() { return yBottRight;}
}

with vector declaration as Vector<Points> vec = new Vector<Points>(); and

//add new element to vector
vec.add(new Pointer(X_TOP_LEFT, Y_TOP_LEFT, X_BOTTOM_RIGHT, Y_BOTTOM_RIGHT));

//retrieve rectangle points
for(Vector<Pointers>point:vec)
{
    //DO WHAT EVER YOU WANT WITH RETRIEVED DATA
    System.out.println("Shape coordinates: "+point.getXTopLeft()+"-"+point.getYTopLeft()+"-"+point.getXBottRight()+"-"+point.getYBottRight());
}
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Is it so difficult to use google with keywords search php+get+date+future.
From what I got from this search even me with no interest in PHP could make that part of the code work...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Font for Label

Label label = new Label("Welcome To Java"); 
Font curFont = label.getFont();
label.setFont(new Font(curFont.getFontName(), Font.BOLD, 20));

About second question I'm not sure. Maybe somebody else can answer that

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

yeah i saw it finally, but i want to see them all together as in the good old days

You are free to state your opinion in DaniWeb Community Feedback. Personally I think that snipped together been good

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

In theory you can create as many timer as you wish, it is the way how you handle them what is important.
Would you mind share the code? You can upload whole project as zip file if you do not mind sharing...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

My apologies for gender confusion, but it was not clear from the name if the person is male or female.

Can you please kindly explain more in details what you trying to achieve? You know "text game" and "i want to display in a label 10 words but not at the same time" are very general terms. So if you can say what functionality you expect out of your game, what is the reason behind flashing 10 words in label or what you trying to achieve, we may be able to give you better advice then just general direction

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

He better explain what he is looking for as that incredible project can have de speakable/ugly/terrible GUI. Why to pass 10 elements of array to same label?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Maybe Practical Apache Struts 2 Web 2.0 Projects can help you.
However I have mixed experience with Apress books. J2ME by them was good, but I had problems with their JSP, JSF and Tomcat Web Development

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If the issue is solved, please mark this post as solved.

Thank you

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Use of code tags [code] YOUR CODE HERE [/code]
or
[code=Java]YOUR CODE HERE [/code]

stephen84s commented: kind of late dont you think, I already blackmailed him in to using them :P +3
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Same question asked here http://www.daniweb.com/forums/thread159180.html
Forum flooding is not welcomed, please read the rules!
Hopefully this will be moved and merge soon in JSP section

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

fName, lName are local variable of addIndividuals() method, therefore you can not use them outside of this method. Hence the zipCode, by some miracle made it (because of the zipCode = zipCode; which may be pure coincidence)
You have to either pass these values as parameters to your toString() method or declare fName, lName in the same manner as zipCode on the start of your class. Sorry, difficult to judge as the code is real mess :S

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Existing with stack of errors meaningful only to you as the programmer, alien to the user is bad design.
You should re trite gratefully with appropriate error message to the user and do not shut down program, just return to the point where the file name been submitted for new entry

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

This neither concerns Java or JavaScript, links are matter of HTML
Somewhere in your page you will place that applet into view surrounded by link tag as this

<a href="#Bottom">APPLET_HERE</a>

and then somewhere in the document you place

<a name="Bottom">Bottom</a>

indicate where is the bottom

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

For the database import, before you attempt to import the "flat" file data in, you need go to your local DB (MySQL) and create new database

create database DATABASE_NAME;

After that you can import.