Thursday, March 27, 2008

Code of HouseEvo

import java.util.*;
public class HouseEvo
{
Scanner input = new Scanner(System.in);
private Box bottom;
private Attic top;
private double depth ;


public HouseEvo()
{
System.out.print(" Enter the depth of the house: ");
double depth = input.nextDouble();
bottom = new Box(depth);
top = new Attic(depth);
System.out.print("The volume of house is: " + bottom.volume() + top.volume());
}

public class Rectangle
{
private double length, height;

public Rectangle()
{
System.out.println("Enter the height of rectangle: " );
height = input.nextDouble();
System.out.println("Enter the length of rectangle: ");
length = input.nextDouble();
}
public double area()
{
return length * height ;
}
}
private class Box
{
private Rectangle front;
private double depth;

public Box(double depth)
{
this.depth = depth;
}
public double volume()
{
return front.area() * depth ;
}
}
private class Attic
{
private Triangle front;
private double depth;

public Attic(double depth)
{
this.depth = depth;
}
private double volume()
{
return front.area() * depth ;
}
}
private class Triangle
{
private double length, height;

public Triangle()
{
System.out.println("Enter the height of Attic : ");
height = input.nextDouble();
}
public double area()
{
return height * length * 0.5;
}
}

}

Tuesday, March 25, 2008

Programming Fundamental Assigment 1 Code

import java.util.Scanner;
import java.util.Random;
import java.util.*;

public class UnifiedDomination
{
private Random rng = new Random(); // Our random number generator
private Scanner input = new Scanner(System.in); // Our keyboard reader

private int australianTerritory1Armies = 4;
private int australianTerritory2Armies = 2;
private int australianTerritory3Armies = 2;
private int australianTerritory4Armies = 1;
private int africanTerritory1Armies = 3;
private int africanTerritory2Armies = 2;
private int africanTerritory3Armies = 3;
private int africanTerritory4Armies = 2;

private String australianPlayerName; // Name of Australian player
private String africanPlayerName; // Name of African player


private String name;
public UnifiedDomination()
{
// Your code goes here.
// Use separate methods and follow design principles to achieve
// a high design mark.

getName();
currentArmies();
battle();
battle();
currentArmies();
}
private void getName()
{
System.out.print("Enter name of player for Australia: ");
australianPlayerName = input.nextLine();
System.out.print("Enter name of player for African: ");
africanPlayerName = input.nextLine();
}
private void currentArmies()

{ System.out.println();
System.out.println("Australia has "+ australianArmies() + " armies.");
System.out.println("African has " + africanArmies() + " armies.");
System.out.println("In total, there are " + totalArmies() + " armies.");
System.out.println();
}
private int australianArmies()
{
return australianTerritory1Armies + australianTerritory2Armies
+ australianTerritory3Armies +australianTerritory4Armies;
}
private int africanArmies()
{
return africanTerritory1Armies + africanTerritory2Armies
+ africanTerritory3Armies + africanTerritory4Armies ;
}
private int totalArmies()
{
return australianArmies() + africanArmies() ;
}
private void battle()
{
int myRandomNumber1 = rng.nextInt(2);
australianTerritory1Armies -= myRandomNumber1;
int myRandomNumber2 = rng.nextInt(2);
africanTerritory3Armies -= myRandomNumber2;
System.out.println( australianPlayerName + " 's Australia Territory 1 fights "
+ africanPlayerName + " 's African Territory 3");


}
// Don't touch this line, leave it here ;-)
public static void main(String[] args) { new UnifiedDomination(); }
}

Wednesday, March 19, 2008

Linux Gym Chap4

Just Remind you of changing permission of public_html which allow others can execute .
Eveything else is simple .
That's it .

Sunday, March 16, 2008

Reflect on the 4th week

-This week ,I'm coming up with the idea of using Mind Map tool to make studying IS easier .Check the progress at weekend
-Begin Review Common Mistake Book 1 .Must finish at weekend
-Think of finding a job .Make money to feed urself and suffer the financial burden along with my parent .
Weaknesses :
- NOT Detemination with myself --> Task 1 : Get up at 8 o'clock every Morning.
- NOT reading Book regularly -> Spend at least 2 hours / week .Find best time of the week to read .
- NOT develop critical thinking -->Unknown Solution .

Saturday, March 15, 2008

Linux Gym Chap3

Source:http://linuxcommand.org/lts0070.php

chmod

The chmod command is used to change the permissions of a file or directory. To use it, you specify the desired permission settings and the file or files that you wish to modify. There are two ways to specify the permissions, but I am only going to teach one way.

It is easy to think of the permission settings as a series of bits (which is how the computer thinks about them). Here's how it works:

rwx rwx rwx = 111 111 111
rw- rw- rw- = 110 110 110
rwx --- --- = 111 000 000

and so on...

rwx = 111 in binary = 7
rw- = 110 in binary = 6
r-x = 101 in binary = 5
r-- = 100 in binary = 4

Now, if you represent each of the three sets of permissions (owner, group, and other) as a single digit, you have a pretty convenient way of expressing the possible permissions settings. For example, if we wanted to set some_file to have read and write permission for the owner, but wanted to keep the file private from others, we would:

[me@linuxbox me]$ chmod 600 some_file

Here is a table of numbers that covers all the common settings. The ones beginning with "7" are used with programs (since they enable execution) and the rest are for other kinds of files.

Value Meaning

777

(rwxrwxrwx) No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.

755

(rwxr-xr-x) The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.

700

(rwx------) The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.

666

(rw-rw-rw-) All users may read and write the file.

644

(rw-r--r--) The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.

600

(rw-------) The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.

Directory permissions

The chmod command can also be used to control the access permissions for directories. In most ways, the permissions scheme for directories works the same way as they do with files. However, the execution permission is used in a different way. It provides control for access to file listing and other things. Here are some useful settings for directories:

Value Meaning

777

(rwxrwxrwx) No restrictions on permissions. Anybody may list files, create new files in the directory and delete files in the directory. Generally not a good setting.

755

(rwxr-xr-x) The directory owner has full access. All others may list the directory, but cannot create files nor delete them. This setting is common for directories that you wish to share with other users.

700

(rwx------) The directory owner has full access. Nobody else has any rights. This setting is useful for directories that only the owner may use and must be kept private from others.

Q :Execute
Execute the file "executable.sh" which you copied in the previous question, and store the output in the file "ex.out" in your ch3-pp directory.
A :
Press " ./filename" to execute a file

Wednesday, March 12, 2008

VIM-Text Editor

Vim's manual:
http://vimdoc.sourceforge.net/htmldoc/usr_toc.html
Vim Mode
http://vimdoc.sourceforge.net/htmldoc/intro.html#vim-modes-intro
Vim quick reference Card
http://tnerual.eriogerg.free.fr/vimqrc.html
Linux Gym 2
Q1 :Insert text
Within your "ch2-vim" directory, create a file called "hw.txt", with only one line of text saying: "hello world" (without the quotes) and save the file.

1. Starting Vim

From the command line you can start editing a file called "test.txt" (whether the file "test.txt" exists or not) with the command:
vim test.txt

2. Switching Modes

There are eleven types of mode when running Vim, but they can be categorised as two types: normal modes and insert modes.

Normal mode: When you start Vim you will be in normal mode, and at any time you can return to the normal mode by pressing the key at the top left-hand side of your keyboard.

Insert mode: There are many ways to enter the insert mode, but the simplest is to type i. After typing i all the characters you type will be inserted into the docuement.

3. Exiting Vim

To exit Vim and return to the command-line:

  1. Go to normal mode by typing
  2. Save and Exit: type :wq which stands for "write and quit".
  3. Exit without saving: typing :q! returns to the command-line without saving the changes you have made to the file
Q2:Join lines
Copy the file "/usr/local/linuxgym-data/vimdata/wordlist.txt" into your "ch2-vim" directory. Edit the file so that all of the text is on a single line with only a space (not a newline) between the words.

A: cp /usr/local/linuxgym-data/vimdata/wordlist.txt .
or
cp /usr/local/linuxgym-data/vimdata/wordlist.txt ./

Don't forget the dot
. at the end. Remember, in UNIX, the dot means the current directory.
Q4:
Deletion by line numbers
Copy the file "/usr/local/linuxgym-data/gutenberg/0ws3110.txt" into your "ch2-vim" directory. Starting at line 50 delete 4000 lines (including line 50) - and save the file. Make absolutely no other changes.
A :
Move to 50 line
then press "4000dd"
Q5:
Cut and paste by line numbers
Copy the file "/usr/local/linuxgym-data/teeny/3mwsm10.txt" into your "ch2-vim" directory. Delete the first 10 lines and append them to the end of the file. Save the file and make no other changes.
A:
delete first 10 lines --> press : 10dd
move to the end of the text ,press : p
Q:Search and replace strings
In the next two questions we have to distinguish between words and strings. A string is a sequence of characters, while a word is a sequence of letters within a string, surrounded by non-word characters. For example, the string "This is a testing time" contains the words "This", "is", "a", "testing" and "time". It does not contain the word "test", but it does contain the string "test".

Copy the file "/usr/local/linuxgym-data/vimdata/hermit.txt" into your "ch2-vim" directory. Replace every occurence of the string "and" with the string "OR". Ensure you make

A
Press
:%s/and/OR/gc -->Confirm every substitution.

Q9:Cut and paste by markers
Copy the file "/usr/local/linuxgym-data/teeny/4mwsm10.txt" into your "ch2-vim" directory. Cut (remove) the lines between (and containing) those with "START HERE" and "UPTO HERE" and insert them at the marker "PASTE HERE". Save the file and make no other changes
A:
Type ':11,64d'

Then 'Paste'--->Shift P



:e![cr] says "I made a right mess of that - abandon my changes and re-read the input file

Sunday, March 9, 2008

Reflect on the second week of Uni

Second week seems going to fast .So Im now in the third week and begin preparation for this week .
Last week, I mentioned abt finding an effective way for uni .Here are some new ideas :
1) Review the lesson on the same day I have lecture .
2) On Monday and Tuesday ,I 'll begin studying the subjects which are taught on Friday first and then on Wednesday , Thursday .
3) and I can do more research during the time I am studying.
Some things needed in my schedule that are sporting time eg.play basketball ,reading time which can be taken place in Park on Weekend , visit Museum.
English :
-How to be a critical thinker
-Writing in field of Science
-Watching TV program to study English as well

ONE MORE IMPORTANT THING : LEARNING AUSTRALIAN CULTURE

Wednesday, March 5, 2008

Research Group

Eddie :
edward.o.chan@student.uts.edu.au
04162448651
Andrea :
andrea_santos90@hotmail.com
0415 911 805
Aninda:
a_das90@hotmail.com
0432 661 518
Ninad :
Ninad_sd1@hotmail.com
0432 737 880

Tuesday, March 4, 2008

Question Arised

1) What languages are used to write Microsoft Window ?


2 )How did they create Unix by C language ?

Sunday, March 2, 2008

Reflect on the first week of Uni

Setting a new schedule for next week ,it could be another busy week.
So what I did last week were getting to know things in Uni .Tried to get acquainted with my flatmate .No too bad,however ,there are some problems which are not to speak as much with them and not feel confident .A major reason is bad pronunciation leading to difficulties for them .-->Need to be improved by Flatmate program of BBC .No worry abt incorrect speaking .Try to speak as much .And especially,don't be shy .

About studying in first week seem good .Goal for next week is still choosing the most effective ways to study .Concentrate on subjects ,and make sure of not sidetracking .1 more goal is , get information and set schedule for finishing first assignment od every subjects .

Writing notes of the subjects which I've studied in the afternoon or morning.By that I can review what I've studied on the day and those notes become references for final exams.

That 's for this week .
See u next week !