Encapsulation in Object Oriented Programming is about keeping data in classes private. The object or data are figuratively placed in a capsule where what is observed by other objects is the capsule not the object or data. inside. This also means that the characteristics of the objects are hidden from direct access. This can mean that the code in the class wont be that affected much with changes in the code made by other people
Purpose:
Protect Object Characteristics from unwanted changes.
Reference:
Head First C#
Wednesday, January 4, 2012
Saturday, December 10, 2011
archorg report
· Includes C++ code that calls the assembly programs
· Includes [4x4][4x1] matrix: computing assembly program
· Includes [4x4][4x2] matrix: computing assembly program
· Includes [4x4][4x4] matrix: computing assembly program
· Tested to see how fast it is executed
Lessons
· Assembly programming
· Better to think of algorithm and pattern before coding in assembly even for simple task
· Adapt to variations of computers. It will not work on some
· Clean up for error and crash report is a good practice when programming
· Balancing schedule with teammates
· Include crashes as a possible delay in schedule
· Comments are even more vital in assembly for understanding code
Saturday, December 3, 2011
Some assembly jump
Carter (2006) pointed out that assembly code can have variations for jumping
| Jump code | jumps/branches if |
|---|---|
| JZ | Zero flag is set |
| JNZ | Zero flag is unset |
| JO | Offset flag is set |
| JNO | Offset flag is unset |
| JS | Sign flag is set |
| JNS | Sign flag is unset |
| JC | Counter flag is set |
| JNC | Counter flag is unset |
| JPE | Parity is even |
| JPO | Parity is odd |
| JMP | Unconditional Jump |
Thursday, November 3, 2011
Friday, October 7, 2011
Java Layout Manager [to be continued]
Time to discuss several kinds of layout managers in java used in java. The layout managers are needed to arrange the components. here the kinds of layout managers to be discussed. The best way to learn is getting the code, run and trace.
Note: sorry if the samples do not look good
The code to generate that is in the Launcher class specifically the BorderLayout(String[] s) method. This layout divides the container using this layout manager into five sections: north,south, east, west, and center.
To insert a component we must use an add method specifically add(Component, some constant)
The constants are:
This layout stacks components from top to bottom or left to right. The constructor has 2 parameters. First the container of the of the box layout and a constant that sets up vertical or horizontal alignment. For example
JPanel optionPane = new JPanel();
BoxLayout box = new BoxLayout(optionPane,
BoxLayout.Y_AXIS);
The lines of code above gives instruction to make the JPanel utilize the Box layout. For horizontal stacking, the BoxLayout.X_AXIS constant can be the second argument in the parameters.
Please note that in horizontal alignment, the box layout manager attempts to give each component the same height. In vertical alignment, it attempts to give each one the same width.
The flow layout is the simplest layout manager to use since components are added like how characters are written in a word processor application.
It can have the following constructors
sample: FlowLayout flo = new FlowLayout(FlowLayout.CENTER, 15, 5);
The default alignment of added components are centered, but the constants FlowLayout.LEFT or FlowLayout.RIGHT to change the alignment of components to be added.
Components are arranged in rows and columns. Components are added first to the top row of the grid, beginning with the leftmost grid cell and continuing to the right. When all the cells in the top row are full, the next component is added to the leftmost cell in the second row of the grid—if there is a second row and so on.
Constructors:
Reference:
Note: sorry if the samples do not look good
- The Border Layout
- The Box Layout
- The Flow Layout
- The Grid Layout
- The Card Layout
The Border Layout
| Sample of components arranged in the Border layout |
The code to generate that is in the Launcher class specifically the BorderLayout(String[] s) method. This layout divides the container using this layout manager into five sections: north,south, east, west, and center.
To insert a component we must use an add method specifically add(Component, some constant)
The constants are:
- BorderLayout.NORTH
- BorderLayout.SOUTH
- BorderLayout.WEST
- BorderLayout.EAST
- BorderLayout.CENTER
The Box Layout
This layout stacks components from top to bottom or left to right. The constructor has 2 parameters. First the container of the of the box layout and a constant that sets up vertical or horizontal alignment. For example
JPanel optionPane = new JPanel();
BoxLayout box = new BoxLayout(optionPane,
BoxLayout.Y_AXIS);
The lines of code above gives instruction to make the JPanel utilize the Box layout. For horizontal stacking, the BoxLayout.X_AXIS constant can be the second argument in the parameters.
Please note that in horizontal alignment, the box layout manager attempts to give each component the same height. In vertical alignment, it attempts to give each one the same width.
Flow layout
The flow layout is the simplest layout manager to use since components are added like how characters are written in a word processor application.
It can have the following constructors
- new FlowLayout();
- new FlowLayout(CONSTANT);
- The alignment, which must be one of five class variables of FlowLayout: CENTER,LEFT, RIGHT, LEADING, or TRAILING
- The horizontal gap between components, in pixels
- The vertical gap, in pixels
sample: FlowLayout flo = new FlowLayout(FlowLayout.CENTER, 15, 5);
The default alignment of added components are centered, but the constants FlowLayout.LEFT or FlowLayout.RIGHT to change the alignment of components to be added.
The Grid Layout
Components are arranged in rows and columns. Components are added first to the top row of the grid, beginning with the leftmost grid cell and continuing to the right. When all the cells in the top row are full, the next component is added to the leftmost cell in the second row of the grid—if there is a second row and so on.
Constructors:
- GridLayout()- default of one column per component, in a single row. May form something like the horizontal box layout
GridLayout(int rows, int cols)-specified number of rows and columns.GridLayout(int rows, int cols, int hgap, int vgap)specified number of rows and columns. and gaps
The default gap between components under a grid layout is 0 pixel in both vertical and horizontal directions much like the Flowlayout where the vertical and horizontal gaps can also be modified. The components under this kind of layout expand to fill the space available to them in each cell unlike other layouts.
Card Layout
| With the card layout the componets shown can change |
A card layout is a group of containers or components displayed one at a time.
The recommended declaration is similar to this. CardLayout cc = new CardLayout();
then the container (Like a JFrame) that will use that layout will have to use the method setLayout(cc);
A different add() method has to be used. Here it is add(String,Component). The container must support that add() method to use the Card Layout where the String is the title/name of the "Card" which is the name that signals to what component to be displayed which is the component beside the string parameter.
After adding the programmer can instruct on what to show when the program is running but a show method must be used. For Example:
cc.show(this, “Fact Card”); or cc.show(JF.getContentPane(), “Fact Card”);
The trigger in changing what to show can happen from an event or other methods.
Reference:
Cadenhead R. and Lemay L. (2007). Sams teach yourself Java 6 in 21 days. United States of America: Sams Publishing.
Wednesday, August 10, 2011
Java Mysql sample program
Not the best deign of GUI or Database but it shows how Mysql can be connected with java.
Please get the mysql-connector-java-5.1.17 and the sql file used here
The links the documents show are the same
Import the sql file downloaded from the link to the mysql server
in CMD
write: mysqldump -u [uname] -p StudentDb > [backupfile.sql]
sample: mysqldump -u root -p StudentDb > F:\INtrodb\Student_data.sql
Then Enter the password of your mysql server
Make sure that the source code is connected to the library downloaded from the mysql java connector so the application will work with mysql properly.
The LogIn class
The CoursePane class
The StudentPane class
The Main class is Obj.java
The Application looks like the images in the pdf below. You can download the pdf from the File Menu.
Tuesday, August 2, 2011
Use of Mutual fund expert system
The Expert System aims to help anyone to choose which kind of mutual fund investment would work best for his/her circumstances in the Philippine setting. The system makes a conclusion that it evaluated to be the best among the options available base on the investor's circumstances but it does not force the investor to pick that option, but it just advises him/her so that the investor can get an expert opinion. The conclusion may also serve as something like a back-up plan for investors since investing is risky no matter what form of investment it is.
Anyone investor can benefit from the system as a guide or a provider of a back-up investment. The system is recommended by young and employed people who are new in investing since they would need an expert opinion on choosing a mutual fund, and being young allows them to take risk unlike older individuals who may not have enough time to recover from loss. Advising the neophyte investors reduces the risk they will get from investing and it also gives them confidence with their investment. Another reason why neophyte investors benefit from this is that mutual funds provides one of the lowest initial capital among investment options, and this system focuses on that topic. Other investors can also benefit from the system since it gives a conclusion that is not baseless and it is applicable, though it would probably serve as plan B to some of them.
Sunday, July 31, 2011
Knowledge Engineering
Knowledge engineering is about putting the knowledge of of an expert to a machine called an expert system. Unfortunately, it is easier said than done since the knowledge of an expert may take awhile to understand and it can be overwhelming to understand the knowledge in a short time. It is even more difficult to provide that knowledge to a computer system since our understanding has to be correct and out coding must also be correct. Time constraints limit the amount of expertise that can be placed on a system but it is possible to build a system with an amount of knowledge that can be compared to an expert. Our experience in building an expert system for mutual funds made us that knowledge engineering on finances also has to be quite qualitative since the personality, situation and interest of the investor has to be considered besides the financial calculations and time. Furthermore, the amount of variations in personality, circumstances and investment options can be really copious which we learned from gathering information. Another thing we learned is that books and other information from the internet which are not always accurate are not enough in knowledge engineering since an expert on the field for so long can provide more in depth and specific explanations that can be provided to the expert system as knowledge since an true expert's knowledge has been tested and proven already and they can also provide information on more specific case than any book or online reference which are mostly general. Our experience in knowledge engineering was quite educational and it did provide stress but it help us appreciate the vast amount of knowledge a person can contain.
Subscribe to:
Posts (Atom)
