زيادة الإنتاجية في إستخدام الحاسوب

الهدف: إيجاد وسيلة لزيادة الإنتاجية أثناء إستخدامي لجهاز الحاسب بحيث أستطيع معرفة الوقت الذي أمضيه في عمل وظائف محددة كمشاهدة عرض تقديمي، إستخدام البريد الإلكتروني ومتابعة الشبكات الإجتماعية.

المطلوب: خدمة ويب مجانية تتيح لي تحقيق هذا الهدف دون تدخل مباشر مني وتوفر لي رسوم بيانية وإحصائيات واضحة عن الوقت الذي أمضيه وتعمل على جميع أنظمة التشغيل التي أستخدمها – ماك وويندوز – مع دعم للبروكسي بحكم أني أعمل معظم الوقت داخل الجامعة.

النتيجة: Rescue Time تطبيق ويب يوفر خدمة مجانية محدودة المميزات بحيث يقوم بجمع معلومات عن نشاطاتك على الحاسوب بتطبيق صغير جداً ويقوم بإرسالها للويب وتحليلها وإظهار النتائج لك بطريقة مناسبة حسب الأيام، الأسابيع، الشهور والسنة.

كمية الإحصائيات والتفاصيل مذهلة وتستطيع منها الحكم على وقتك الذي تمضيه وتستطيع أن تقرر مدى حاجتك لتغير بعض عاداتك الحاسوبية :)

الترم الدراسي 091

اليوم سيكون آخر يوم في الترم الدراسي 091 وسينتهي بحلوه ومره وسنبدأ الإختبارات النهائية صباح السبت القادم بإذن الله.

تخلل هذا الترم بعض الفعاليات التي حضرتها في كل من دبي والرياص حيث أني حضرت معرص جايتكس في دبي وحضرت الندوة الثانية للحاسب واللغة العربية في الرياض وكلها كانت في شهر أكتوبر.

كتبت جريدة اليوم مقالُ عني والشكر موصول لعاصم الغامدي “معدن”.

عملت في هذا الترم الدراسي مع فريق رائع في مادة SWE205 وقمنا بتسليم المشروع النهائي في الوقت وبجودة عالية وسأتحدث عن ذلك في موضوع منفصل لاحقاً.

إنضممت هذا الترم إلى مجموعة PSD Groups وموقع المجموعة يحتوي على كل ما تريدون معرفته :)

الترم القادم غير واضح المعالم بعد لكن أحاول أن أجعله ترماُ ملياُ بالإنجازات وعلى أصعدة مختلفة جديدة.

آآه نسيت! فقد فقدت جهاز الماك بسبب حادث في التكيف! والتفاصيل طويلة ولا أريد الخوض فيها وقد تبعه الهارد دسك الذي يحتوي على النسخ الإحتياطية الوحيدة وبهذا فقدت كل ما أملكه من ملفات وعدت إلى نقطة الصفر. لذلك بدأت أستخدم Drop Box كحل مثالي لعمل نسخ إحتياطية لملفاتي ومزامنتها مع باقي أجهزتي دون تدخل مباشر مني:) وأنصح الجميع بتجربته.

هذا ما دار في جعبتي. أراكم لا حقاً :)

سيرة ذاتية من صفحة واحدة للويب بالعربية والإنجليزية

لقد انتهيت من عمل النسخة العربية للسيرة الذاتية والذي يعتمد على النسخة الإنجليزية من مدونة CSS-TRICKS وهذا رابط تحميل النسخة الإنجليزية وأخر للمعاينة.

بالنسبة للنسخة العربية فتستطيع معاينتها من هنا. وهذا هو رابط التحميل.

كل ما قمت به في النسخة العربية هو تعديل كود CSS وذلك بتغير اتجاه النصوص وتغير بعض القيم لكي تعرض المحتويات بالشكل المطلوب.

كود CSS للنسخة الإنجليزية.

 * { margin: 0; padding: 0; }
        body { font: 16px Helvetica, Sans-Serif; line-height: 24px; background: url(images/noise.jpg); }
        .clear { clear: both; }
        #page-wrap { width: 800px; margin: 40px auto 60px; }
        #pic { float: right; margin: -30px 0 0 0; }
        h1 { margin: 0 0 16px 0; padding: 0 0 16px 0; font-size: 42px; font-weight: bold; letter-spacing: -2px; border-bottom: 1px solid #999; }
        h2 { font-size: 20px; margin: 0 0 6px 0; position: relative; }
        h2 span { position: absolute; bottom: 0; right: 0; font-style: italic; font-family: Georgia, Serif; font-size: 16px; color: #999; font-weight: normal; }
        p { margin: 0 0 16px 0; }
        a { color: #999; text-decoration: none; border-bottom: 1px dotted #999; }
        a:hover { border-bottom-style: solid; color: black; }
        ul { margin: 0 0 32px 17px; }
        #objective { width: 500px; float: left; }
        #objective p { font-family: Georgia, Serif; font-style: italic; color: #666; }
        dt { font-style: italic; font-weight: bold; font-size: 18px; text-align: right; padding: 0 26px 0 0; width: 150px; float: left; height: 100px; border-right: 1px solid #999;  }
        dd { width: 600px; float: right; }
        dd.clear { float: none; margin: 0; height: 15px; }

كود CSS للنسخة العربية.

* { margin: 0; padding: 0; }
        body { font: 16px Verdana, Helvetica, Arial, sans-serif; line-height: 24px; background: url(noise.jpg);text-align: right; direction: rtl; }
        .clear { clear: both; }
        #page-wrap { width: 800px; margin: 40px auto 60px;  }
        #pic { float: left; margin: -30px 0 0 0; }
        h1 { margin: 0 0 16px 0; padding: 0 0 16px 0; font-size: 42px; font-weight: bold; border-bottom: 1px solid #999;  }
        h2 { font-size: 20px; margin: 0 0 6px 0; position: ; }
        h2 span { position: relative; bottom: 0; right: 10px; font-style: italic; font-family: Georgia, Serif; font-size: 16px; color: #999; font-weight: normal; }
        p { margin: 0 0 16px 0; }
        a { color: #999; text-decoration: none; border-bottom: 1px dotted #999; }
        a:hover { border-bottom-style: solid; color: black; }
        ul { margin: 0 17px 32px 0; }
        #objective { width: 500px; float: left; }
        #objective p { font-family: Verdana, Helvetica, Arial, sans-serif; font-style: italic; color: #666; }
        dt { font-style: italic; font-weight: bold; font-size: 18px; text-align: left; padding: 0 0 0 20px; width: 100px; float: right; height: 100px; border-left: 1px solid #999;  }
        dd { width: 600px; float: right; padding: 0 20px 0 0; }
        dd.clear { float: none; margin: 0; height: 15px; }

كود HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ar-sa" lang="ar-sa">

<head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

     <title>سيرة ذاتية من صفحة واحدة</title>

     <style type="text/css">
        * { margin: 0; padding: 0; }
        body { font: 16px Verdana, Helvetica, Arial, sans-serif; line-height: 24px; background: url(noise.jpg);text-align: right; direction: rtl; }
        .clear { clear: both; }
        #page-wrap { width: 800px; margin: 40px auto 60px;  }
        #pic { float: left; margin: -30px 0 0 0; }
        h1 { margin: 0 0 16px 0; padding: 0 0 16px 0; font-size: 42px; font-weight: bold; border-bottom: 1px solid #999;  }
        h2 { font-size: 20px; margin: 0 0 6px 0; position: ; }
        h2 span { position: relative; bottom: 0; right: 10px; font-style: italic; font-family: Georgia, Serif; font-size: 16px; color: #999; font-weight: normal; }
        p { margin: 0 0 16px 0; }
        a { color: #999; text-decoration: none; border-bottom: 1px dotted #999; }
        a:hover { border-bottom-style: solid; color: black; }
        ul { margin: 0 17px 32px 0; }
        #objective { width: 500px; float: left; }
        #objective p { font-family: Verdana, Helvetica, Arial, sans-serif; font-style: italic; color: #666; }
        dt { font-style: italic; font-weight: bold; font-size: 18px; text-align: left; padding: 0 0 0 20px; width: 100px; float: right; height: 100px; border-left: 1px solid #999;  }
        dd { width: 600px; float: right; padding: 0 20px 0 0; }
        dd.clear { float: none; margin: 0; height: 15px; }
     </style>
</head>

<body>

    <div id="page-wrap">

        <img src="cthulu.png" alt="Photo of Cthulu" id="pic" />

        <div id="contact-info" class="vcard">

            <!-- Microformats! -->

            <h1 class="fn">اسمك هنا!</h1>

            <p>
                جوال: <span class="tel">0561234567</span><br />
                البريد الإلكتروني: <a class="email" href="mailto:someone@somewhere.com">someone@somewhere.com</a>

            </p>
        </div>

        <div id="objective">
            <p>
                هذا نموذج لسيرة ذاتية. تقوم هنا بكتابة بعض الجمل التي تعبر عنك! لم يخطر ببالي شئ
				استطيع الكتابة عنه هنا لكن تستطيع الإجتهاد وكتابة ماتريد مع مراعاة أنك تقوم بكتابة سيرة ذاتية
				وليست قصة حياتك! هذا نموذج لسيرة ذاتية. تقوم هنا بكتابة بعض الجمل التي تعبر عنك! لم يخطر ببالي شئ
				استطيع الكتابة عنه هنا لكن تستطيع الإجتهاد وكتابة ماتريد مع مراعاة أنك تقوم بكتابة سيرة ذاتية
				وليست قصة حياتك!
            </p>
        </div>

        <div class="clear"></div>

        <dl>

            <dd class="clear"></dd>

            <dt>التعليم</dt>
            <dd>
                <h2>جامعة الملك فهد للبترول والمعادن</h2>
                <p><strong>التخصص:</strong> هندسة برمجيات<br />
                   <strong>المعدل:</strong> 4.0/4.0</p>

            </dd>

            <dd class="clear"></dd>

            <dt>المهارات</dt>
            <dd>
                <h2>المهارات المكتبية</h2>
                <p>مدير مكتب، منسق أحداث، منسق سفر، ترتيب وتصنيف الملفات</p>

                <h2>برامج الحاسوب</h2>

                <p>حزمة برامج مايكروسوفت المكتبية، حزمة برامج أبل المكتبية، مجموعة أدوبي للتصميم</p>
            </dd>

            <dd class="clear"></dd>

            <dt>الخبرات</dt>
            <dd>
                <h2>الجامعة المحلية <span>مساعد إداري، السعودية من 2007 إلى 2009	</span></h2>
                <ul>

                    <li>الوصف الأول للعمل الجيد الذي كنت فيه</li>
                    <li>الوصف الثاني للعمل الجيد الذي كنت فيه</li>
                    <li>الوصف الثالث للعمل الجيد الذي كنت فيه</li>
                </ul>

                <h2>الجامعة الخارجية <span>مدير مكتب، الإمارات من 2005 إلى 2007</span></h2>
                <ul>

                    <li>الوصف الأول للعمل الجيد الذي كنت فيه</li>
                    <li>الوصف الثاني للعمل الجيد الذي كنت فيه</li>
                    <li>الوصف الثالث للعمل الجيد الذي كنت فيه</li>
                </ul>
            </dd>

            <dd class="clear"></dd>

            <dt>الهوايات</dt>

            <dd>الغوص، القفز من الجسور، تسلق الجبال</dd>

            <dd class="clear"></dd>

            <dt>مراجع</dt>
            <dd>منوفرة عند الطلب</dd>

            <dd class="clear"></dd>
        </dl>

        <div class="clear"></div>

    </div>

</body>

</html>

ICS 201 Final Project

عملت على هذا المشروع مدة 3 ساعات وقد كان في الأسبوع الأخير من الترم الصيفي 083

Design and implement a memory game. In this game you show the user a sequence of random integer numbers in the range of 0 to 99, and then ask him to type these umbers. Display how many he has remembered as a score. The level of game depends on how many numbers are there in the sequence. The duration of the display for the sequence is the speed. The user can adjust the level and the speed.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Random;
public class project extends JFrame
{
Random generator = new Random();
int ran = 0;
int count = 1;
int score = 0;
String input = "";
String rand = "";
String theLevel = "Beginner";
String Speed = "3 Seconds";
int theSpeed = 3000;
Timer t;
JButton button = new JButton("Play");
JButton button1 = new JButton("Reset");
JLabel num = new JLabel("Press the button \"Play\" to play");
JLabel s = new JLabel("You score is: " + score + "| Your Level is: " + theLevel + "| your Speed is: " + Speed);
public project()
{
super("The Memory Game");
setSize(500,150);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new BorderLayout( ));
JMenu level = new JMenu("Level");
JMenuItem beginner = new JMenuItem("Beginner");
beginner.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
theLevel = "Beginner";
s.setText("You score is: " + score + "| Your Level is: " + theLevel + "| your Speed is: " + Speed);
}
});
level.add(beginner);
JMenuItem average = new JMenuItem("Average");
average.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
theLevel = "Average";
s.setText("You score is: " + score + "| Your Level is: " + theLevel + "| your Speed is: " + Speed);
}
});
level.add(average);
JMenuItem professional = new JMenuItem("Professional");
professional.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
theLevel = "Professional";
s.setText("You score is: " + score + "| Your Level is: " + theLevel + "| your Speed is: " + Speed);
}
});
level.add(professional);
JMenu speed = new JMenu("Speed");
JMenuItem three_sec = new JMenuItem("3 Seconds");
three_sec.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
theSpeed = 3000;
Speed = "3 Seconds";
s.setText("You score is: " + score + "| Your Level is: " + theLevel + "| your Speed is: " + Speed);
}
});
speed.add(three_sec);
JMenuItem six_sec = new JMenuItem("6 Seconds");
six_sec.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
theSpeed = 6000;
Speed = "6 Seconds";
s.setText("You score is: " + score + "| Your Level is: " + theLevel + "| your Speed is: " + Speed);
}
});
speed.add(six_sec);
JMenuItem ten_sec = new JMenuItem("10 Seconds");
ten_sec.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
theSpeed = 10000;
Speed = "10 Seconds";
s.setText("You score is: " + score + "| Your Level is: " + theLevel + "| your Speed is: " + Speed);
}
});
speed.add(ten_sec);
JMenu about = new JMenu("About");
JMenuItem aboutme = new JMenuItem("About");
aboutme.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
JOptionPane.showMessageDialog(null, "This program developed by:\nEmad Daghreri\nemad.daghreri@gmail.com","alert" , JOptionPane.ERROR_MESSAGE);
}
});
about.add(aboutme);
JMenuBar bar = new JMenuBar( );
bar.add(level);
bar.add(speed);
bar.add(about);
setJMenuBar(bar);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new GridLayout (4,1));
add(mainPanel,BorderLayout.CENTER);
mainPanel.setBackground(Color.WHITE);
mainPanel.add(num);
mainPanel.add(s);
mainPanel.add(button);
mainPanel.add(button1);
setVisible(true);
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
if (theLevel.equals("Beginner"))
{
for(int i = 0; i<2;i++)
{
button.setVisible(false);
button1.setVisible(false);
rand = rand + generator.nextInt(99);
num.setText("The number is: "+rand);
}
t = new Timer(theSpeed, new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
num.setText("");
input=JOptionPane.showInputDialog("Pleas enter the number: ");
if(input.equalsIgnoreCase(rand))
{
score ++;
s.setText("You score is: " + score + "| Your Level is: " + theLevel + "| your Speed is: " + Speed);
num.setText("Nice !");
} else num.setText("Sorry, try again!");
button.setVisible(!false);
button1.setVisible(!false);
rand = "";
t.stop();
}
});
t.start();
}
if (theLevel.equals("Average"))
{
for(int i = 0; i<3;i++)
{
button.setVisible(false);
button1.setVisible(false);
rand = rand + generator.nextInt(99);
num.setText("The number is: "+rand);
}
t = new Timer(theSpeed, new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
num.setText("");
input=JOptionPane.showInputDialog("Pleas enter the number: ");
if(input.equalsIgnoreCase(rand))
{
score ++;
s.setText("You score is: " + score + "| Your Level is: " + theLevel + "| your Speed is: " + Speed);
num.setText("Nice !");
} else num.setText("Sorry, try again!");
button.setVisible(!false);
button1.setVisible(!false);
rand = "";
t.stop();
}
});
t.start();
}
if (theLevel.equals("Professional"))
{
for(int i = 0; i<4;i++)
{
button.setVisible(false);
button1.setVisible(false);
rand = rand + generator.nextInt(99);
num.setText("The number is: "+rand);
}
t = new Timer(theSpeed, new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
num.setText("");
input=JOptionPane.showInputDialog("Pleas enter the number: ");
if(input.equalsIgnoreCase(rand))
{
score ++;
s.setText("You score is: " + score + "| Your Level is: " + theLevel + "| your Speed is: " + Speed);
num.setText("Nice !");
} else num.setText("Sorry, try again!");
button.setVisible(!false);
button1.setVisible(!false);
rand = "";
t.stop();
}
});
t.start();
}
}
});
button1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
num.setText("Press the button \"Play\" to play");
score = 0;
theLevel = "Beginner";
Speed = "3 Seconds";
theSpeed = 3000;
s.setText("You score is: " + score + "| Your Level is: " + theLevel + "| your Speed is: " + Speed);
}
});
}
public static void main(String[]args)
{
new project();
}
}

ICS102 Final Project

ICS102 Project File

ICS102Project.java

/*|||  About The Code  |||
 * version 9.09 2009/6/7
 ************************/

 /*||||||||||||||||  INDEX  ||||||||||||||||
 *Imports.
 *		Scanner.
 *		PrintWriter.
 *		JOptionPane.
 *Public Class.
 * 		Main Method.
 * 				Accounts checker.
 * 				Commands dialog.
 * 		Dan Method.
 *		Ret Method.
 *		Add Method.
 *		Ava Method.
 *		Res Method.
 ******************************************/

// Imports.
	import java.util.Scanner;
	import java.io.*;
	import javax.swing.*;
// End: Imports.

public class ICS102Project {
// Main Method.
    public static void main(String[] args)throws Exception{
	// Accounts checker.
    	Scanner Accounts=new Scanner(new File("DATA/account.txt"));	//The file(account) contains users and passwords
    	String[] account=new String[100];
    	int g=0;
    	while(Accounts.hasNextLine()){
    		account[g]=Accounts.nextLine();	//Filling the array with the accounts, each cell will have user&password separated by (:)
    		g++;
    	}

    	Accounts.close();

    	//A welcome dialog
    	JOptionPane.showMessageDialog(null,"Welcome to the Airline Reservation System\nA project");
    	String input=null,read=null,user=null;

    	int check=0;
    	// The do-while will check if the user and password are available & comform
    	do{
    		int userCheck=0;
    		    		input=JOptionPane.showInputDialog("Administrator Control Panel\n\nPleas enter the username: ");

    		for(int i=0; i<g; i++){
    			read=account[i];
    			user=read.substring(0,read.indexOf(":"));	//because the user and the password are in one line and separated by (:)
    			if(user.equals(input)){
    				userCheck=1;
    				break;
    			}
    		}
    		if(userCheck==1){
    			input=JOptionPane.showInputDialog("Administrator Control Panel\n\nEnter Your Password: ");
    			if((read.substring(read.indexOf(":")+1)).equals(input))
    				break;
    			else{
    				JOptionPane.showMessageDialog(null,"Sorry\nWrong Password !");
    				check++;
    			}
    		}
    		else{
    			JOptionPane.showMessageDialog(null,"Sorry\nWrong Username !");
    			check++;
    		}

    	// As a seafty, the system will close after three wrong inputs or three wrong matches...
    	}while(check!=3);

    	if(check==3){
    		JOptionPane.showMessageDialog(null,"You've exeeded the limit!\nPlease contact our support team!");
    		System.exit(0);
    	}
// Emd: Accounts checker.
// Commands & commands dialog.
		String danInfo=null;
    	input=JOptionPane.showInputDialog("Administrator Control Panel\n\nEnter a command:  ");
    	String command=null;
    	String data=null;

		// the command ( q! ) will end the program
    	while(!(input.equals("q!"))){

			// To avoid getting wrong input less than 3 digits
    		if(input.length()>3)
    			{
    			command=input.substring(0,3);
    			data=input.substring(4);
    			if(command.equalsIgnoreCase("dan")){
					// airport information
    				danInfo=dan(data);
    				JOptionPane.showMessageDialog(null,"Administrator Control Panel\n\nAirport Code: "+danInfo);
    			}
    			else if(command.equalsIgnoreCase("ret")){
					// return a reservation information
    				ret(data);
    			}
    			else if(command.equalsIgnoreCase("add")){
					// add a new flight or flights
    				add(input);
    			}
    			else if(command.equalsIgnoreCase("ava")){
					// check for availability of a flight
    				ava(data);

    			}
    			else if(command.equalsIgnoreCase("res")){
					// making new reservation...
    				res(data);
    			}
    			else if(command.equalsIgnoreCase("tkt")){
					// printing a tkt data...
    				Ticket.getTKT(data);
    			}
				else if(command.equalsIgnoreCase("hlp")){
					// printing a tkt data...
    				JOptionPane.showMessageDialog(null,"Enter the command like\ndan jed\n3 leaters for the command then space rhen the data\n:)");
    			}
    			else
    				JOptionPane.showMessageDialog(null,"Administrator Control Panel\n\nNot valid command !\nEnter \"hlp me\" for Help");
    		}
    		else
    			JOptionPane.showMessageDialog(null,"Administrator Control Panel\n\nNot valid command !\nEnter \"hlp me\" for Help");
    		input=JOptionPane.showInputDialog("Administrator Control Panel\n\nEnter a command:  ");
    	}

    	JOptionPane.showMessageDialog(null,"Administrator Control Panel\n\nYou loged of !\nThank You :) ");
// End: Commands & commands dialog.
    }
// End: Main Method.
// Dan Method.
    public static String dan(String cityName)throws Exception{
		// The method dan will lock for an airport information using the code for a city.
    	String line=null;
    	Scanner in=new Scanner(new File("DATA/iata-airport-codes.txt"));
    	while(in.hasNextLine()){
    		line=in.nextLine();
    		if((line.toLowerCase()).contains(cityName.toLowerCase())){
    			in.close();
    			return line;
    		}
    	}
    		return "City not found, check the spelling!";
    }
// End: Dan Method.
// Ret Method.
	public static void ret(String fileName)throws Exception{
			// Thw method ret will return a valid reservation information using reservation number.
    		String line=null;
			String infoFull="\n";
    		Scanner out=new Scanner(new File("DATA/booking/"+fileName+".txt"));
    		while(out.hasNextLine()){
    			line=out.nextLine();
				infoFull = infoFull + line + "\n";
    		}
			JOptionPane.showMessageDialog(null,"Administrator Control Panel\n\nInformation for the reservation "+fileName+" are:"+infoFull);

    		out.close();
    }
// End: Ret Method.
// Add Method.
	public static void add(String flight)throws Exception{
			// This method will add new flights to the file ( DATA/availability.txt ).
			String line=null;

			// To mack sure that all the old data in availability.txt saved to a temp. file while adding new flights
			Scanner out=new Scanner(new File("DATA/availability.txt"));
			PrintWriter in1=new PrintWriter(new File("DATA/copy.txt"));
			while(out.hasNextLine()){
				line=out.nextLine();
				in1.println(line);
			}
			in1.close();
			out.close();

			// To return the copied flights to the origin file ( DATA/availability.text ) then to add new flights..
			Scanner out1=new Scanner(new File("DATA/copy.txt"));
			PrintWriter in=new PrintWriter(new File("DATA/availability.txt"));
			while(out1.hasNextLine()){
				line=out1.nextLine();
				in.println(line);
			}
			String month=(flight.substring(12,13)).toUpperCase()+(flight.substring(13,15)).toLowerCase();
			String dep=(flight.substring(4,7)).toUpperCase();
			String des=(flight.substring(7,10)).toUpperCase();
			String fClass=(flight.substring(15,19)).toUpperCase();
			String jClass=(flight.substring(19,23)).toUpperCase();
			String yClass=(flight.substring(23)).toUpperCase();
			if((flight.substring(10,12)).equals("**"))
			// ** means the whole month ( 30 days = 30 flights ).
				{

				for(int i=1; i<=30; i++){
					// To add a digit to the numbers less than 10..
					if(i<10)
						in.print("0");
					in.println(i+" "+month+" "+dep+" "+des+" "+fClass+" "+jClass+" "+yClass);

				}
			}
			else
				in.println(flight.substring(10,12)+" "+month+" "+dep+" "+des+" "+fClass+" "+jClass+" "+yClass);
		        JOptionPane.showMessageDialog(null,"Administrator Control Panel\n\nThe Flight:\n" +flight.substring(10,12)+" "+month+" "+dep+" "+des+" "+fClass+" "+jClass+" "+yClass + "\n" + "Added to DATA");
			out1.close();
			in.close();
		}
// End: Add Method.
// Ava Method.
		public static String ava(String check)throws Exception{
			// To check the availability of a flight.
			Scanner in=new Scanner(new File("DATA/availability.txt"));
			int count=1;
			String line=null;
			check=check.substring(0,2)+" "+check.substring(2,5)+" "+check.substring(5,8)+" "+check.substring(8);
			while(in.hasNextLine()){
				line=((in.nextLine()).toLowerCase());
				if(line.contains(check.toLowerCase())){

					JOptionPane.showMessageDialog(null,"Administrator Control Panel\n\nSearch Result:\n" + line.toUpperCase());

					return line.toUpperCase();
				}

			}
				JOptionPane.showMessageDialog(null,"Administrator Control Panel\n\nSorry, There is no available flight for\n" + check);

				return "";
    }
// End: Ava Method.
// Res Method.
		public static void res(String flight)throws Exception{

		// To book a new reservation.. and add a passengers & make tickets for them...
    	String lastName=null;
    	String givenName=null;
    	int seat=Integer.parseInt(flight.substring(12,13));

		// To check the availability of seats number
    	String classType=(flight.substring(13,14)).toUpperCase();
    	String comFlight=flight.substring(15)+"/";
    	String com2Flight=null;
    	String deleteFlight=ava(flight.substring(6,11)+flight.substring(0,6));
    	com2Flight=deleteFlight.substring(15);
    	int seats=Integer.parseInt(com2Flight.substring(com2Flight.indexOf(classType)-3,com2Flight.indexOf(classType)));
    	if(seats<seat){
    		JOptionPane.showMessageDialog(null,"Administrator Control Panel\n\nSorry, There is no seats available");
    		return;
    	}

    	seats-=seat;
    	String sseats=null;
    	if(seats<10)
    		sseats="00"+seats;
    	else if(seats<100)
    		sseats="0"+seats;
    	else
    		sseats=""+seats;
    	String newFlight=""+deleteFlight.substring(0,com2Flight.indexOf(classType)+12)+sseats+deleteFlight.substring(com2Flight.indexOf(classType)+15);

    	Scanner out=new Scanner(new File("DATA/availability.txt"));	// After booking a new reservation,, here the file availability will be updated and seats of the flight will decrease..
		PrintWriter in1=new PrintWriter(new File("DATA/copy.txt"));
		String line=null;
		while(out.hasNextLine()){
			line=out.nextLine();
			in1.println(line);
		}
		in1.close();
		out.close();

		Scanner out1=new Scanner(new File("DATA/copy.txt"));
		PrintWriter in=new PrintWriter(new File("DATA/availability.txt"));
		while(out1.hasNextLine()){

			line=out1.nextLine();
			if(line.equalsIgnoreCase(deleteFlight))
				in.println(newFlight);
			else
				in.println(line);
		}
		in.close();
		out1.close();
		Scanner out2=new Scanner(new File("DATA/res_num.txt"));	// To generate a new reservation number...
		int num=out2.nextInt();
		num++;
		out2.close();

		PrintWriter in2=new PrintWriter(new File("DATA/res_num.txt"));
		in2.print(num);
		in2.close();
		String fileName=""+num;
		PrintWriter in3=new PrintWriter(new File("DATA/booking/"+fileName+".txt"));
		int price=Integer.parseInt(JOptionPane.showInputDialog("Administrator Control Panel\n\nEnter The Price of one ticket"));
		in3.println("Departure city: "+(flight.substring(0,3)).toUpperCase());
		in3.println("Destination city: "+(flight.substring(3,6)).toUpperCase());
		in3.println("Day: "+flight.substring(6,8));
		in3.println("Months: "+flight.substring(8,11));
		in3.println("Year: 2010");// The program will be valid in 2010 because Saudi aielines will use my program for one year in 2010....<< nice comment
		in3.println("Class: "+classType);
		in3.println("Number of seats: "+seat);
		String mobile=null;
		String tktNum=null;

		for(int i=1; i<=seat; i++){// to print the passengers one by one .. depends on seats number....
			lastName=comFlight.substring(0,comFlight.indexOf(";"));
			givenName=comFlight.substring(comFlight.indexOf(";")+1,comFlight.indexOf("/"));
			mobile=JOptionPane.showInputDialog("Administrator Control Panel\n\nEnter passenger No."+i+"   phone number: ");
			tktNum="065210"+fileName+i+i;
			Ticket p_data=new Ticket(givenName,mobile,fileName,tktNum,flight.substring(0,3).toUpperCase(),flight.substring(3,6).toUpperCase(),price);	

			Scanner ticketsInformation=new Scanner(new File("DATA/tkt.txt"));
			String test1 = "";
			String test2 = "";
			while(ticketsInformation.hasNextLine()){
    		test1=ticketsInformation.nextLine();
    		if(test1.contains(tktNum)){
    			test2 = test2 + test1;
    			while(ticketsInformation.hasNextLine()){
    			test2 = test2 + "\n" + ticketsInformation.nextLine();
    			}
    			JOptionPane.showMessageDialog(null,"Administrator Control Panel\n\nTicket information\n" + test2); 

    			in.close();

    			}

    		}

			comFlight=comFlight.substring(comFlight.indexOf("/")+1);
			in3.println("Passenger "+i+":");
			in3.println("Last Name: "+lastName);
			in3.println("Given Name: "+givenName);
		}
		in3.close();
    }
// End: Res Method.
}

Ticket.java

/*|||  About The Code  |||
 * version 5.07 2009/6/8
 ************************/

// Imports.
	import java.util.Scanner;
	import java.io.*;
	import javax.swing.*;
// End: Imports.

public class Ticket {
	// The attributes
    private String passengerName;
    private String mobile;
    private String reservationNumber;
    private String tktNumber;
    private String departure;
    private String destination;
    private int price;
    // the setters and the getters
    public void setPassengerName(String passengerName){
    	this.passengerName=passengerName;
    }
    public String getPassengerName(){
    	return passengerName;
    }

    public void setMobile(String mobil){
    	this.mobile=mobile;
    }
    public String getMobile(){
    	return mobile;
    }

    public void setReservationNumber(String reservationNumber){
    	this.reservationNumber=reservationNumber;
    }
    public String getReservationNumber(){
    	return reservationNumber;
    }

    public void setTktNumber(String tktNumber){
    	this.tktNumber=tktNumber;
    }
    public String getTktNumber(){
    	return tktNumber;
    }

    public void setDeparture(String departure){
    	this.departure=departure;
    }
    public String getDeparture(){
    	return departure;
    }

    public void setDestination(String destination){
    	this.destination=destination;
    }
    public String getDestination(){
    	return destination;
    }

    public void setPrice(int price){
    	this.price=price;
    }
    public int getPrice(){
    	return price;
    }
    // This is the constructor which will take the attributes from the main method
    public Ticket(String name,String phone,String resNum,String tktNum,String dep,String des,int pr)throws Exception{
    	passengerName=name;
    	mobile=phone;
    	reservationNumber=resNum;
    	tktNumber=tktNum;
    	departure=dep;
    	destination=des;
    	price=pr;
    	storeTKT();
    	// Calling the method to store it in the file ( DATA/tkt.txt)
    }
    // This method will store the attributes in a file
    public void storeTKT()throws Exception{
    	// We need to print every thing in DATA/tkt.txt file into a copy then returning the data again.. this is how to update the file without deleting the old data..
    	Scanner out=new Scanner(new File("DATA/tkt.txt"));
    	PrintWriter in=new PrintWriter(new File("DATA/copyTKT.txt"));
		String line=null;
		while(out.hasNextLine()){
			line=out.nextLine();
			in.println(line);
		}
		in.close();
		out.close();

		Scanner out1=new Scanner(new File("DATA/copyTKT.txt"));
		PrintWriter in1=new PrintWriter(new File("DATA/tkt.txt"));
		while(out1.hasNextLine()){
			line=out1.nextLine();
			in1.println(line);
		}
		in1.println("eTKT Number: "+tktNumber);
		in1.println("reservation Number: "+reservationNumber);
		in1.println("Passenger Name: "+passengerName);
		in1.println("Phone Number: "+mobile);
		in1.println("Departure City: "+departure);
		in1.println("Destination City: "+destination);
		in1.println("Price: "+price+" SR");
		in1.println("&&&&&&&&");//this will give us an easy way to separate the tkt's ...
    	in1.close();
    	out1.close();
    }
    // this method will take number of the tkt and give it to other method to print it..
    public static void getTKT(String tktNum)throws Exception{
    		int check=0;
    	Scanner out=new Scanner(new File("DATA/tkt.txt"));
    	String line=null;
    	while(out.hasNextLine()){
    		line=out.nextLine();
    		if(line.contains(tktNum)){
    			check=1;
    			break;
    		}
    	}
    	if(check==0){
    		JOptionPane.showMessageDialog(null,"No tkt Number available...");
    		return;
    	}
    	while(!(line.equals("&&&&&&&&"))){
    		printTKT(line);
    		line=out.nextLine();
    	}
    	out.close();
    }
    // this method will print tkt data
    public static void printTKT(String line){

    	System.out.println(line);
    }

}

DB Files