Java was the first language I learned in College. Here are some interesting things I have done.

DrawBookstore InventoryContent Queueing SystemSchool Roster
Drawing program

A drawing program to create masterpieces using the latest methods! ie. Square, Circle, Line and Pen tools. Undo and redo functionality. You can also add text and a nifty background color to shock and awe the masses.


javadraw

 
Mark: A+
 
Code Snippet:
[cc lang=’csharp’ ]
public void mousePressed(MouseEvent e) {
        //When the mouse is pressed, begin drawing a shape
        //Or text, depending on the current action.
        if(!mIsDrawing) {
            mIsDrawing = true;
            mIsDrawingShapeOriginPoint = e.getPoint();
            switch(mCurrentAction) {
                case DRAW_RECT:
                    mIsDrawingShape = new Rectangle(e.getPoint());
                    break; 
                case DRAW_CIRCLE: 
                    mIsDrawingShape = new Ellipse2D.Double(mIsDrawingShapeOriginPoint.x,
                           mIsDrawingShapeOriginPoint.y, mIsDrawingShapeOriginPoint.x-e.getX(),
                            mIsDrawingShapeOriginPoint.y-e.getY());
                    break;    
                case DRAW_LINE:
                    mIsDrawingShape = new Line2D.Double();
                    break;
                case DRAW_PENCIL:
                    mIsDrawingShape = new Path2D.Double();
                    ((Path2D.Double)mIsDrawingShape).moveTo(e.getX(), e.getY());
                    break;
                case DRAW_TEXT:
 
                    mIsDrawing = false;
                    String test = javax.swing.JOptionPane.showInputDialog(“Type something here!”);
                    mIsDrawingText = new JLabel();
                    mIsDrawingText.setSize(100, 55);
                    mIsDrawingText.setText(test);
                    mIsDrawingText.setLocation(e.getX(), e.getY());
                    checkTextArray();
                    for (int t = 0; t < mAllText.length; t++) {                          if (isTextArrayHaveSpace) {                             if (mAllText[t] == null){                             add(mIsDrawingText);                             mAllText[t] = mIsDrawingText;                             repaint();                             break;                             }                         }                     }                     break;                 default:                     mIsDrawing = false;                     break;             }         }                  repaint();     } [/cc] [/tab] [tab title="MusicZinger"]Final Project for Java 2. Music Zinger, despite its really cheesy name, is a Java application that’s main purpose is to create simple songs with a basic drum kit, bass and guitar sounds. The application will allow the user the ability to design a simple song using toggle buttons, the ability to save that song; and to recall it to be played again at any time. Data that will be tracked is the user inputs for the instruments and percussion as well as the title and ‘artist’ name, comments and the date created. This application is made for users who need a quick and simple way to make a tune. The user can be a developer or just anyone who wants to play around with music without the learning curve or complicated applications. The music created can be for a website or for a game the user could be developing. Mark: A+ (although the gui needs a facelift lol) [gallery columns="5" ids="182,181,180,184,183"] [cc lang='csharp'] private void playEmG() { if (reset) { // Builds empty sounds into an array // to account for songs that have gaps // other wise the song would skip the gap // even if you wanted a gap, this solves the problem for (int v = 0; v < 16; v++) { AssociatedTone newTone = new AssociatedTone(new JToggleButton("-"), "g", 0, v); nulls.add(newTone); nullsConstructionCheck = true; } //This part finds the empty spaces in the array of sounds //that way, when it is played, it will know where to 'pause' // and not play a sound. int[] calculateDelay = new int[16]; for (int i = 0; i < 16; i++) { for (int z = 0; z < 8; z++) { if (gToggles[i][z].getText().equals(note)) { calculateDelay[i] = i; } } } for (int v = 0; v < associatedTonesArrayListG.size(); v++) { AssociatedTone get = (AssociatedTone) associatedTonesArrayListG.get(v); nulls.set(get.numX, get); } // This part will play through the sound array, delaying each iteration // this also will check and make sure that a sound should played // if no sound should play, there is a gap in the sounds of an appropriate amount for (int v = 0; v < nulls.size(); v++) { AssociatedTone get = (AssociatedTone) nulls.get(v); if (get.numY > 0) {
s.playSound(get.getType() + get.numY);
try {
Thread.sleep(300);
} catch (InterruptedException ex) {
JOptionPane.showMessageDialog(null, “Please try again, there was a problem.”);
}
} else {
try {
Thread.sleep(600);
} catch (InterruptedException ex) {
JOptionPane.showMessageDialog(null, “Please try again, there was a problem.”);
}
}
}
}
}
[/cc]

A bookstore inventory organizer. Connect to a database that contains the book information. Add, Update and Delete records. Simple stuff.

Mark: A+

Simple Code Snippet:
[cc lang=’csharp’ ]
public BookFrame() {
initComponents();
//Sets text fields so they can’t be edited.
setEditable(false, false);
try {
results.first();
if (results.first()) {
//sets initial text fields.
codeTextField.setText(bk.getCode());
titleTextField.setText(bk.getTitle());
priceTextField.setText(bk.getPrice());
}
} catch (SQLException ex) {
//Nothing needs to be done for this project.
}
}
[/cc]

Final Project for Java3.

The purpose of this program is to enable research companies to organize materials for review. The CQS (Content Queuing System) will organize and keep track of articles, documents and other media that you plan on viewing. We are so busy in the day that it is hard to keep track of the articles and media that we wish to view. Often while browsing the internet, we find interesting articles but we are too busy to actually read them. This system will help you queue these articles, allowing you to set a priority and a deadline to complete viewing to keep you up to date on information that you need.

Mark: A+


P.S. This isn’t the most secure program, security wasn’t a requirement at all for this assignment.

Simple Code Snippet:
[cc lang=’csharp’ ]
//Check if user exists, if it does redirect.
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException, NoSuchAlgorithmException {
response.setContentType(“text/html;charset=UTF-8”);

PrintWriter out = response.getWriter();

username = request.getParameter(“username”);
password = request.getParameter(“password”);

if(username.isEmpty()){ out.println(“

ERROR:

Must enter username“);
return;
}
if(password.isEmpty()){ out.println(“

ERROR:

Must enter password“);
return;
}

username = escapeHTML(username);
password = escapeHTML(password);

udb = new UsersDB(“SELECT * FROM Users WHERE Username = ‘”+username+”‘ AND Password = ‘”+password+”‘;”);
ResultSet results = udb.getResultSet();
Users u = new Users(results);
udb.moveFirst(u);
if(u.getUsername() == null ){
out.println(“

ERROR:

There ”
+ “is a problem with the username or password, you may need to sign up”
+ “

Sign Up“);
return;
}
out.println(u.getId());

//Hash and Cookies – If all good redirect to main page
Hash h = new Hash();
hashdigest = h.hash(username, password);
Cookie cookie = new Cookie(“Session”, hashdigest);
cookie.setPath(“/”);
response.addCookie(cookie);
try {
out.println(“
“);
out.println(““);
response.sendRedirect(“All”);
} finally {
out.close();
}
}
[/cc]

This project was for Java 2. It’s function is complete a list of Faculty and Students, save it to a ‘.dat’ file and recall the file to display them in a small form. In addition to the main form there is also a ‘.dat’ generator that has a small form and saves it to file.

Mark: Also an A+


Simple Code Snippet:
[cc lang=’csharp’ ]
private void updateJList(){
for(Person p : peopleList){
if((p instanceof Employee) || (p instanceof Faculty)){
employeeModel.addElement(p);
}
else if(p instanceof Student){
studentModel.addElement(p);
}
}
}
[/cc]
This is an ad!