Jump to content


Check out our Community Blogs

Coldhearth

Member Since 02 Oct 2008
Offline Last Active Jan 15 2010 01:16 AM
-----

Topics I've Started

Learning the linux command line - Bash

29 December 2009 - 05:05 AM

Hi,

In school we will learn linux (the terminal - bash) in a few weeks.
But I would like to start on my own using linux and therefor I read you should know the command line.

Can anyone point me out to a good book that covers the command line (bash)?
I'm using Ubuntu 9.10 as my linux OS :)

Thanks!

Need help with exercise: Flight reservation system

13 December 2009 - 12:38 PM

Hi, I'm currently working on a flight reservation system (basic though it is) for school for my Java class. This system connects with a MySQL database for testing purposses.
I'm should work with the MVC (model view controller) pattern they said.
This is what I have so far...

Main (start of my application):
import view.MainJFrame;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		MainJFrame application = new MainJFrame();
		application.setVisible(true);
	}

}

MODEL:
Person class:
package model;

public class Person {

	private String lastName;
	private String firstName;
	private String street;
	private int number;
	private int zipCode;
	private String city;
	
	public Person(){
		this("", "", "", 0, 0, "");
	}
	
	public Person(String lastName, String firstName, String street, int number, int zipCode, String city){
		setLastName(lastName);
		setFirstName(firstName);
		setStreet(street);
		setNumber(number);
		setZipCode(zipCode);
		setCity(city);
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public int getNumber() {
		return number;
	}

	public void setNumber(int number) {
		this.number = number;
	}

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	public int getZipCode() {
		return zipCode;
	}

	public void setZipCode(int zipCode) {
		this.zipCode = zipCode;
	}
	
	
	
}

Customer class:
package model;

public class Customer extends Person{

	private String customerID;

	public Customer(){
		this("", "", "", 0, 0, "", "");
	}
	
	public Customer(String lastName, String firstName, String street, int number, int zipCode, String city, String customerID){
		super(lastName, firstName, street, number, zipCode, city);
		setCustomerID(customerID);
	}
	
	public String getCustomerID() {
		return customerID;
	}

	public void setCustomerID(String customerID) {
		this.customerID = customerID;
	}
	
}

Employee class:
package model;

public class Employee extends Person{

	private String username;
	private String password;
	private String employeeID;
	
	public Employee(){
		this("", "", "", 0, 0, "", "", "", "");
	}
	
	public Employee(String lastName, String firstName, String street, int number, int zipCode, String city, String username, String password, String employeeID){
		setUsername(username);
		setPassword(password);
		setEmployeeID(employeeID);
	}

	public String getEmployeeID() {
		return employeeID;
	}

	public void setEmployeeID(String employeeID) {
		this.employeeID = employeeID;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}
	
	
	
}

Flight class:
package model;

public class Flight {
	private String flightNumber;
	private String name;
	private String date;
	private String info;
	
	public Flight(){
		this("", "", "", "");
	}
	
	public Flight(String flightNumber, String name, String date, String info){
		setFlightNumber(flightNumber);
		setName(name);
		setDate(date);
		setInfo(info);
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public String getFlightNumber() {
		return flightNumber;
	}

	public void setFlightNumber(String flightNumber) {
		this.flightNumber = flightNumber;
	}

	public String getInfo() {
		return info;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	
}

VIEW:
MainJFrame class:
(this class will only show a button and textare for now, if I click the button It should get flight info of all my flights in the database)
package view;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JTextArea;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class MainJFrame extends javax.swing.JFrame {
	private JButton btn_showFlightInfo;
	private JTextArea txa_showFlightInfo;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				MainJFrame inst = new MainJFrame();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public MainJFrame() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			BorderLayout thisLayout = new BorderLayout();
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(thisLayout);
			{
				btn_showFlightInfo = new JButton();
				getContentPane().add(btn_showFlightInfo, BorderLayout.SOUTH);
				btn_showFlightInfo.setText("Flight info");
				btn_showFlightInfo.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("btn_showFlightInfo.actionPerformed, event="+evt);
						//TODO add your code for btn_showFlightInfo.actionPerformed
						txa_showFlightInfo.setText("ljl");
					}
				});
			}
			{
				txa_showFlightInfo = new JTextArea();
				getContentPane().add(txa_showFlightInfo, BorderLayout.CENTER);
			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

I also have a MysqlDatabaseConnection class that handles queries like SELECT, INSERT, UPDATE and DELETE for a MySQL database.

My questions now are:
- Am I starting out good (is the MVC structure good so far)
- How should I build this MVC structure now?
- In what part of the MVC structure do I put my database related classes?

Any help will be appreciated :)

MVC in Java

13 December 2009 - 08:51 AM

Hi,

I was looking at the tutorials for Java on CodeCall and I couldn't find a single one discribing how MVC should work preferably with an example exercise...

Does anyone have one or are there on the internet some good ones...
I'd like to develop Java desktop applications and would like to get to know this pattern cause it's supposed to be very good for this kind of programs.

Thank! :)

Beginner programming ideas and exercies

11 December 2009 - 02:17 PM

Hi,

I'm looking for fun programming ideas to learn Java. I'm not really experienced but I would like some ideas about what to create with Java.
For example a simple Notepad application.

Any great ideas on exercises would be super :)

Getting the hang on the "OOP thinkin process"

30 November 2009 - 06:20 AM

Hi, I've been studying applied informatics for 2 year now and they teach us all sorts of languages ranging from COBOL to Java and C#/.NET.

But one thing keeps bothering me... the thinking process of "Object Oriented Programming" :(
I can create simple applications in Java and in PHP and C# but once I get to the point I have to start a whole application just from a text with the problem case in I get stuck.

I can't seem to get the hang on the "thinking process" behind "Object Oriented Programming" :(

Can anyone help me with this cause I really have to be able to think in this way to become a good programmer!

Books, tutorials, anything... that trains you in "thinking OOP".
(As languages I prefer Java and PHP - Java mostly - for the books or examples)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download