Nicholas Lefebvre

Greenhorn
+ Follow
since Feb 05, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nicholas Lefebvre

I am making a database to store information on people who are competing in a competition. I have created my database in access. When i run my code i get this error





This is my code.
I want to start making games in java. What do i need to know before i start. Where should i start.
10 years ago
I dont know how to start setting up the database but i do know how to start the data base is access but MySQL and that i dont know.So could you tell me the steps involved.
11 years ago
I need to make a program that can aoutomaticaly create and asign a ID number to a new item but the ID number can not be repeated once. How would i do that the rest of the program is working i just need to genereate it.
11 years ago
i mean the types of database drivers.
I don't understand the differences between the database types.
I have never worked with databases before. I have only used text files. Could someone give me an example of the code that is needed for a database to connect to the program. I have never used SQL before.
Would XML be a better option. I have never used data bases or XML
The program needs to be able to run on a web page would that require me to do anything different
I have to make an application which stores:
Names
Surnames
Status
Age
Division
IP address
Games that the person plays

All of that need to be stored in a Microsoft database. I can set up a access database no problem. But i have no clue how to link it to the java program. Which needs to be able to search the data base for any of listed information above and display which person/person have it in common. Please can someone help me with this.


So how would i break the code if the id number is not 13
11 years ago
11 years ago
I finished a number to vaildate south african id numbers. I wounder if there where any mistakes I made and if there were any ways to make it shorter. Please can you look at my code and tell me any tips or criticism you might have which i will used to learn from. Thanks

import java.util.Calendar;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* NewJFrame.java
*
* Created on Mar 27, 2013, 11:14:51 AM
*/
/**
*
* @author Nicholas.Lefebvre
*/
public class NewJFrame extends javax.swing.JFrame {

/** Creates new form NewJFrame */
public NewJFrame() {
initComponents();
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jInternalFrame1 = new javax.swing.JInternalFrame();
jLabel1 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jTextField5 = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jInternalFrame1.setVisible(true);

jLabel1.setText("Enter ID Number :");

jLabel2.setText("Lenght :");

jTextField2.setEditable(false);

jLabel3.setText("AGE :");

jTextField3.setEditable(false);
jTextField3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField3ActionPerformed(evt);
}
});

jTextField4.setEditable(false);

jLabel4.setText("Status :");

jButton1.setText("SUBMIT");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jTextField5.setEditable(false);

jLabel5.setText("Gender");

javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
jInternalFrame1Layout.setHorizontalGroup(
jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)
.addComponent(jLabel2)
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addGap(196, 196, 196)
.addComponent(jButton1)))
.addContainerGap(158, Short.MAX_VALUE))
);
jInternalFrame1Layout.setVerticalGroup(
jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addGap(31, 31, 31)
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(32, 32, 32))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jInternalFrame1, javax.swing.GroupLayout.Alignment.TRAILING)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jInternalFrame1)
);

pack();
}// </editor-fold>

private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

//check lenght methode
String Idnumber = jTextField1.getText();
int lenght = Idnumber.length(); //Gets the lenght of the string and stores it in the variable lenght
System.out.println(lenght);// prints the lenght that is stored in lenght

if(lenght==13){
jTextField2.setText("Correct");
}else{
jTextField2.setText("Incorrect");
}

// end of check lenght

//method to validate the id number
int d1 = Integer.parseInt(""+Idnumber.charAt(0));
int d2 = Integer.parseInt(""+Idnumber.charAt(1));
int d3 = Integer.parseInt(""+Idnumber.charAt(2));
int d4 = Integer.parseInt(""+Idnumber.charAt(3));
int d5 = Integer.parseInt(""+Idnumber.charAt(4));
int d6 = Integer.parseInt(""+Idnumber.charAt(5));
int d7 = Integer.parseInt(""+Idnumber.charAt(6));
int d8 = Integer.parseInt(""+Idnumber.charAt(7));
int d9 = Integer.parseInt(""+Idnumber.charAt(8));
int d10 = Integer.parseInt(""+Idnumber.charAt(9));
int d11 = Integer.parseInt(""+Idnumber.charAt(10));
int d12 = Integer.parseInt(""+Idnumber.charAt(11));
int d13 = Integer.parseInt(""+Idnumber.charAt(12));


String dd1 = d1+"";
String dd2 = d2+"";
String dd3 = d3+"";
String dd4 = d4+"";
String dd5 = d5+"";
String dd6 = d6+"";
String dd7 = d7+"";
String dd8 = d8+"";
String dd9 = d9+"";
String dd10 = d10+"";
String dd11 = d11+"";
String dd12 = d12+"";

int totalA = d1+d3+d5+d7+d9+d11;



String B = dd2+dd4+dd6+dd8+dd10+dd12;

int totalB= Integer.parseInt(B);
int b= 2;
int t;
t=b*totalB;
String totalBa = Integer.toString(t) ;


int totalB1 = Integer.parseInt(""+totalBa.charAt(0));
int totalB2 = Integer.parseInt(""+totalBa.charAt(1));
int totalB3 = Integer.parseInt(""+totalBa.charAt(2));
int totalB4 = Integer.parseInt(""+totalBa.charAt(3));
int totalB5 = Integer.parseInt(""+totalBa.charAt(4));
int totalB6 = Integer.parseInt(""+totalBa.charAt(5));
int totalB7 = Integer.parseInt(""+totalBa.charAt(6));

int totalC = totalB1 + totalB2 + totalB3 + totalB4 + totalB5 + totalB6 + totalB7;
System.out.println("totalc"+totalC);
int totalD = totalC + totalA;


int controldigit=totalD%10;
System.out.println("totalD =" + totalD);
System.out.println("control digit =" +controldigit);

if(d1==controldigit){
jTextField3.setText("VALID ID NUMBER");
}else{
jTextField3.setText("VALID ID NUMBER");
}

//end of validate ID number methode

// start of determine age methode
String dateOfBirth= dd1+dd2;
int yeara = 1900;

int yearb = 2000;




int dateofbirthint= Integer.parseInt(dateOfBirth);

int dateofBirthB;

if (dateofbirthint<20){

dateofBirthB = dateofbirthint + yearb;


}else{

dateofBirthB = dateofbirthint + yeara;
}

int year = Calendar.getInstance().get(Calendar.YEAR);

int age = year - dateofBirthB ;
String ages = Integer.toString(age);
jTextField4.setText(ages);
//end of determine age method

//start of determine gender

String genderdigits = dd7+dd8+dd9+dd10;
int genderintdigit = Integer.parseInt(genderdigits);

if(genderintdigit<5000){
jTextField5.setText("Female");
}else{
jTextField5.setText("Male");
}
//end of determine gender


}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {

@Override
public void run() {
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JInternalFrame jInternalFrame1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
// End of variables declaration
}
11 years ago