Jump to content


Check out our Community Blogs

Coldhearth's Content

There have been 37 items by Coldhearth (Search limited from 15-February 18)



Sort by                Order  

#534003 Learning the linux command line - Bash

Posted by Coldhearth on 29 December 2009 - 05:05 AM in Linux

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!



#532837 Java Book

Posted by Coldhearth on 19 December 2009 - 04:26 AM in Java

I'm using Deitel - Java How To Program 6th edition :) Very good book in my opinion.



#532835 Nid help in boolean type array..

Posted by Coldhearth on 19 December 2009 - 04:20 AM in Java

Just like any other array I suppose :)
This simple sample program might help...:
public static void main(String[] args) {
		Scanner input = new  Scanner(System.in);
		// Initialize the boolean array
		boolean[] booleanArray = new boolean[9];
		
		//Give in true of false for each array element (fill up the array)
		for(int i=0; i<9; i++){
			System.out.printf("Give in true or false for array element %d", i);
			boolean value = input.nextBoolean();
			booleanArray[i] = value;
		}
		
		//Show the array elements
		for(boolean element : booleanArray)
			System.out.printf("%s ", element);
		
	}



#531806 Need help with exercise: Flight reservation system

Posted by Coldhearth on 14 December 2009 - 07:16 AM in Java

Does somebody know a source code example of a simple exercise that uses the MVC pattern with a MySQL database for the data?
An example would be very good to study and learn from :)



#531703 Need help with exercise: Flight reservation system

Posted by Coldhearth on 13 December 2009 - 12:38 PM in Java

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 :)



#531677 MVC in Java

Posted by Coldhearth on 13 December 2009 - 08:51 AM in Java

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! :)



#531366 Beginner programming ideas and exercies

Posted by Coldhearth on 11 December 2009 - 03:41 PM in Java

Thx for the links :) but these are exercises for little pieces of programming.
I'll use them :) but what I meant was a good idea to make a small program like a little NotePad or some sort of other simple programs like an agenda, etc...
Anyone any good ideas? Keep in mind that I'm still a beginning programmer.



#531346 Beginner programming ideas and exercies

Posted by Coldhearth on 11 December 2009 - 02:17 PM in Java

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 :)



#528797 Getting the hang on the "OOP thinkin process"

Posted by Coldhearth on 30 November 2009 - 01:10 PM in General Programming

I know it's a completely different thinking process...
My question is how do I teach myself to learn to think in therm of objects and relations between objects, methods and attributes...

Do a books like "The Object Oriented Thought Process 3th edition" or "Head First: Object Oriented Analysis and Design" teach me those skills or are they focusing on other stuff?



#528776 Writing simple forum PHP/MySQL

Posted by Coldhearth on 30 November 2009 - 12:08 PM in PHP

Yeah but why should I do that... I won't learn anythin from that :s



#528703 getting started with programming

Posted by Coldhearth on 30 November 2009 - 06:23 AM in General Programming

In my opinion (I'm just a beginning programmer ofcourse...) it doesn't really matter what language you start with. Logical thinking is way more important to a programmer than the language he's using. If you know the syntax of a language but aren't able to solve a problem effectively you can't do anything...
So just pick one for the platform you want to develop.
If you wanna do desktop development pick C or C++
For the web PHP or C# with .NET
Otherwise Java is also good for applications that are cross-platform. :)



#528702 Getting the hang on the "OOP thinkin process"

Posted by Coldhearth on 30 November 2009 - 06:20 AM in General Programming

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)



#528695 Problem building AJAX/PHP guestbook

Posted by Coldhearth on 30 November 2009 - 04:26 AM in PHP

Lol it was the letter C in stateChanged that did the trick ;)
But when I change step 2 or 3 like you suggest it calls up the php page and inserts it right there in the page :)
So I left it "submit" in the button.
Thx!!!



#528692 Writing simple forum PHP/MySQL

Posted by Coldhearth on 30 November 2009 - 04:13 AM in PHP

Hi,

Can anybody suggest some good books or tutorials or whatever to writing a simple forum.
I would like to do this to practise my PHP/MySQL skills and raise them to the next level.

Forum should include:
  • User registration
  • User login
  • Administration trough a front-end
  • Administration throug a back-end
  • And other basic stuff



#528341 Problem building AJAX/PHP guestbook

Posted by Coldhearth on 28 November 2009 - 09:55 AM in PHP

Yes :)



#528338 Problem building AJAX/PHP guestbook

Posted by Coldhearth on 28 November 2009 - 09:33 AM in PHP

Okay my script is like this now:

addmessage.php
<?php

require_once("config.php");

$name = $_GET['name'];
$email = $_GET['email'];
$message = $_GET['message'];

$query = "INSERT INTO posts (name, email, message) VALUES ('$name','$email', '$message')";

$result = mysqli_query($conn, $query) or diet("Error executing insert query.");

if($result){
echo "Message added";
}

?>


showmessages.php
<?php

require_once("config.php");

$query = "SELECT * FROM posts ORDER BY id DESC";

$result = mysqli_query($conn, $query) or die("Error executing read query.");

while($row = mysqli_fetch_object($result)){
if(mysqli_num_rows($result)>0){
$name = $row->name;
echo $name . "<br />";
}else{
echo "No messages in the guestbook yet...";
}
}

?>


index.php
<html>
<head>
<title>Guestbook V1.1</title>
<script type="text/javascript">

// Used in showMessages NOT IN getXmlHttpObject()!!!
var xmlHttp;

function showMessages(){
xmlHttp = getXmlHttpObject();
if(xmlHttp == null){
alert("Your browser does not support Javascript");
return;
}

var url = "showmessages.php";
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}

function postMessage(){
xmlHttp = getXmlHttpObject();
if(xmlHttp == null){
alert("Your browser does not support Javascript");
return;
}
var name = document.postform.name.value;
var email = document.postform.email.value;
var message = document.postform.message.value;
var url = "addmessage.php?name="+name+"&email="+email+"&message="+message;
xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}

function stateChanged(){
if(xmlHttp.readyState == 4){
document.getElementById("messages").innerHTML=xmlHttp.responseText
}
if(xmlHttp.readyState == 3){
document.getElementById("messages").innerHTML="Loading3...";
}
if(xmlHttp.readyState == 2){
document.getElementById("messages").innerHTML="Loading2...";
}
if(xmlHttp.readyState == 1){
document.getElementById("messages").innerHTML="Loading1...";
}
if(xmlHttp.readyState == 0){
document.getElementById("messages").innerHTML="Loading0...";
}
}

function getXmlHttpObject(){
var xmlHttp = null;
try{
//Firefox, opera, safari,...
xmlHttp = new XMLHttpRequest();
}catch(e){
try{
//IE
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
//IE other
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}

</script>
</head>
<body>

<h3>Guestbook V1.1</h3>
<div id="messages">
<script type="text/javascript">
showMessages();
</script>
</div>

<h3>Post a message</h3>
<div id="postform">
</div><form name="postform" id="postform" method="post">
Name:*<br />
<input type="text" name="name" id="name" /><br />
Email:*<br />
<input type="text" name="email" id="email" /><br />
Message:*<br />
<textarea cols="60" rows="6" name="message" id="message"></textarea><br />
<input type="reset" value="Reset" />
<input type="submit" value="Post message" onclick="postMessage()" />
</form>
</div>

</body>
</html>


Still just flickers the page and doesn't add anything to the database.
Like the script isn't even called... :s



#528296 Problem building AJAX/PHP guestbook

Posted by Coldhearth on 28 November 2009 - 06:37 AM in PHP

Erhm... :P that's a good question... can you please explain this to me? :)



#528284 Problem building AJAX/PHP guestbook

Posted by Coldhearth on 28 November 2009 - 05:37 AM in PHP

Changed the 2 sends to POST and now it doesn't do anything anymore... :P
It just flickers my page and empties the form... no posts added to the DB...



#528282 Problem building AJAX/PHP guestbook

Posted by Coldhearth on 28 November 2009 - 05:15 AM in PHP

I'm currently starting to build some applications in PHP to learn the language and I've started with a guestbook.
Everything works except for the part that's supposed to add a message to the guestbook.

The problem isn't the PHP code for adding a message but the AJAX...
Instead of adding a post and doing it in the background it keeps going to the addmessage.php page... and because it's supposed to be AJAX there shouldn't be a page reload...

If anyone can help me solve this problem and give me some tips on what to add to the guestbook like security or other stuff I forgot...

My code is:

addmessage.php
<?php

require_once("config.php");

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

$query = "INSERT INTO posts (name, email, message) VALUES ('$name','$email', '$message')";

$result = mysqli_query($conn, $query) or diet("Error executing insert query.");

if($result){
echo "Message added";
}

?>


showmessages.php
<?php

require_once("config.php");

$query = "SELECT * FROM posts ORDER BY id DESC";

$result = mysqli_query($conn, $query) or die("Error executing read query.");

while($row = mysqli_fetch_object($result)){
if(mysqli_num_rows($result)>0){
$name = $row->name;
echo $name . "<br />";
}else{
echo "No messages in the guestbook yet...";
}
}

?>


Index.php
<html>
<head>
<title>Guestbook V1.1</title>
<script type="text/javascript">

// Used in showMessages NOT IN getXmlHttpObject()!!!
var xmlHttp;

function showMessages(){
xmlHttp = getXmlHttpObject();
if(xmlHttp == null){
alert("Your browser does not support Javascript");
return;
}

var url = "showmessages.php";
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}

function postMessage(){
xmlHttp = getXmlHttpObject();
if(xmlHttp == null){
alert("Your browser does not support Javascript");
return;
}
var name = document.postform.name.value;
var email = document.postform.email.value;
var message = document.postform.message.value;
var url = "addmessage.php?name="+name+"&email="+email+"&message="+message;

xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}

function stateChanged(){
if(xmlHttp.readyState == 4){
document.getElementById("messages").innerHTML=xmlHttp.responseText
}
if(xmlHttp.readyState == 3){
document.getElementById("messages").innerHTML="Loading3...";
}
if(xmlHttp.readyState == 2){
document.getElementById("messages").innerHTML="Loading2...";
}
if(xmlHttp.readyState == 1){
document.getElementById("messages").innerHTML="Loading1...";
}
if(xmlHttp.readyState == 0){
document.getElementById("messages").innerHTML="Loading0...";
}
}

function getXmlHttpObject(){
var xmlHttp = null;
try{
//Firefox, opera, safari,...
xmlHttp = new XMLHttpRequest();
}catch(e){
try{
//IE
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
//IE other
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}

</script>
</head>
<body>

<h3>Guestbook V1.1</h3>
<div id="messages">
<script type="text/javascript">
showMessages();
</script>
</div>

<h3>Post a message</h3>
<div id="postform">
</div><form name="postform" id="postform" method="post" action="addmessage.php">
Name:*<br />
<input type="text" name="name" id="name" /><br />
Email:*<br />
<input type="text" name="email" id="email" /><br />
Message:*<br />
<textarea cols="60" rows="6" name="message" id="message"></textarea><br />
<input type="reset" value="Reset" />
<input type="submit" value="Post message" onclick="postMessage()" />
</form>
</div>

</body>
</html>



#525833 Programming a forum of CMS in PHP OOP

Posted by Coldhearth on 16 November 2009 - 05:19 AM in PHP

I'd like to create a forum or a CMS system (basic at first then add richer features) with PHP but it has to be object oriented.
I have some experience with Java but I was wondering if any of you have some good books that will help me achieve his goal...?



#524148 Analysing a problem case

Posted by Coldhearth on 10 November 2009 - 12:20 AM in Java

Thank you very much oxano :) that's a really helpful post ^^
I'll try to use this for other problem cases :)
I'm a starting programmer so I have some issues turning problem cases into programs... :)



#523924 Booting Linux (Ubuntu) from portable HD??

Posted by Coldhearth on 09 November 2009 - 11:01 AM in Linux

I'm using a macbook pro generation 1-1 and a imac that about 1 year old so... :)



#523900 Booting Linux (Ubuntu) from portable HD??

Posted by Coldhearth on 09 November 2009 - 09:41 AM in Linux

Hi,

I was wondering if it would be possible to use a portable HD (Iomega - Prestige Portable Hard Drive) as a boot disk for Linux (Ubuntu 9.10 and other versions also probably).

I would like to install Linux on the portable harddrive and then use that same linux distro on different computers in my home or at school.

Also the disk should be able to save data from windows and/or mac computers without affecting the space made avalaible for the Linux distro.

Is this all possible? :) I would buy a drive from 500GB



#523855 Analysing a problem case

Posted by Coldhearth on 09 November 2009 - 08:51 AM in Java

I have heard something about analysing the text of a problem case by filtering nouns and verbs and so to find classes, instance variables and methods....
Some trick to filter unnecessary information to create the program...?



#523694 Searching designer

Posted by Coldhearth on 08 November 2009 - 01:50 PM in HTML, CSS and Javascript

Hi, my name is Gert-Jan I am 20 years old and study Informatics at Ghent - Belgium and I am searching for a designer to work with together to make some websites preferrably earn some money along the way and learn more about webdevelopment.

I'm looking for someone who only does the design of a website in Photoshop. I will do the rest of the development process because I'm a terrible designer ;)

If anyone is interested let me know :)




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