Archive for the ‘Programming’ Category

Example Code #3 – Basics in Prolog

December 28th, 2008 No comments

1- Parent relation between rex, doggie and goldie


Query -> ?dog(goldie) : YES
Query -> ?dog(jack) : YES

2- Sister relation


Query -> ?sister(lili,maria) : NO

3- Finds factorial of numbers

1!: 1 , 2!: 2×1, 3!: 3x2x1
Here you can see that we are able to say 3!: 3×2! instead of 3!:3x2x1 . Since i know what is 1! and 0! therefore i have limitation points for my program.

fact(N,F,F1) :- N1 is N-1, fact(N1,F1), F is N * F1.

Read more…

VN:F [1.9.22_1171]
Rating: 7.0/10 (3 votes cast)
VN:F [1.9.22_1171]
Rating: -1 (from 1 vote)

Example Code #2 – JOptionPane JCombobox

December 21st, 2008 No comments

This code shows how to add ComboBox property to JOptionPane.showInputDialog. And the class is able to take an input from this combobox

import javax.swing.JOptionPane;

public class Options {

	public Options() {

		String smallList[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
				"Thrusday", "Friday", "Saturday" };

Read more…

VN:F [1.9.22_1171]
Rating: 7.1/10 (8 votes cast)
VN:F [1.9.22_1171]
Rating: +4 (from 4 votes)

Example Code #1 – JOptionPane and ArrayList

December 20th, 2008 No comments

Here this class takes some values using JOptionPane.showInputDialog and shows them to the user using foreach loop

import java.util.ArrayList;
import javax.swing.JOptionPane;

public class Confirm {

ArrayList fruits = new ArrayList();

String value = "";
while (true){
value = JOptionPane.showInputDialog("Which fruit to Add?");

Read more…

VN:F [1.9.22_1171]
Rating: 6.7/10 (7 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

CodeIgniter How to Pagination

November 12th, 2008 3 comments

CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. If you’re a developer who lives in the real world of shared hosting accounts and clients with deadlines, and if you’re tired of ponderously large and thoroughly undocumented frameworks.

CodeIgniter’s Pagination class is very easy to use, and it is 100% customizable, either dynamically or via stored preferences.

If you are not familiar with the term “pagination”, it refers to links that allows you to navigate from page to page, like this:

« First < 1 2 3 4 5 > Last »

function shownews()
//checking for security purposes
$per_page = 10; 
// How many pages you want to show in each page
$total = $this->db->get('posts', $per_page, $this->uri->segment(3)); 

//Here is the most important part actually. 
Basically $total variable determined which 
rows you are going to show in the page

$config['base_url'] = base_url().'/index.php/admin/shownews';
$config['total_rows'] = $this->db->count_all('posts'); // Count total rows in the query
$config['per_page'] = $per_page;
$config['num_links'] = 6;
$data['posts'] = $total;
$this->load->view('admin_shownews', $data);
} else {

After getting done with this configuration part of pagination class all you have to do is just initialize it like you are doing it in most of programming languages.

Read more…

VN:F [1.9.22_1171]
Rating: 7.1/10 (41 votes cast)
VN:F [1.9.22_1171]
Rating: -1 (from 5 votes)

Tutorial #3 – Pizza Order in C#

November 11th, 2008 1 comment

Here is my new pizza order tutorial for you. In this tutorial you are able to control checkboxes and radiobuttons together and show them into a message box window.

Codes below…

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
public partial class pizza : Form

//Some global strings to keep radiobutton and checkbox events text's.
private String a1 = null;
private String a2 = null;
private String a3 = null;
private String menu = null;

public pizza()

Read more…

VN:F [1.9.22_1171]
Rating: 5.9/10 (9 votes cast)
VN:F [1.9.22_1171]
Rating: -1 (from 1 vote)
Categories: C#, Programming Tags: , , ,