Ambition : 1.Graduate UTS and do Master Degree by Scholarship . 2.Learn another language (Japan) 3.Travel (Japan)
Thursday, March 27, 2008
Code of HouseEvo
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.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
Eveything else is simple .
That's it .
Sunday, March 16, 2008
Reflect on the 4th week
-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