Saturday, December 10, 2011

archorg report

Project description and code

http://www.mediafire.com/?r2y3q9mb0dou1b3

·         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 codejumps/branches if
JZZero flag is set
JNZZero flag is unset
JOOffset flag is set
JNOOffset flag is unset
JSSign flag is set
JNSSign flag is unset
JCCounter flag is set
JNCCounter flag is unset
JPEParity is even
JPOParity is odd
JMPUnconditional Jump

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 Border Layout
  • The Box Layout
  • The Flow Layout
  • The Grid Layout
  • The Card Layout
Here is the source code hopefully the link works if it does the download the file and open the .bat file to see the program


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
So the constant used when adding a components will determine the part where the component will be inserted in the layout. For example  JF.add(new JLabel("This is the north",JLabel.CENTER),BorderLayout.NORTH); that line of code will insert a JLabel to the northern part of the layer of JF.

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 FlowLayout(int, int, int) constructor takes the following three arguments, in order:

  • 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.

    Tuesday, July 26, 2011

    Websites





    Great websites


    http://Maypasokba.com/



    A simple informative and relevant website to inform students if there is classes. This website provides life saving information. The provided information is concise and clear.

    The site

    As you see the website has a simple clean and clear interface. The headline and the sub text gives the information the site visitors need. The site also has links to the source of the information

    PCMAG.com






    This website is like is informative in reporting the latest developments in technology. The reviews on the products are reliable and the reports are accurate. The sites home page is organized and the categories are clear. The colors does not hurt the eyes. The articles interest me and they are easy to read and understand. The ads are bearable.


    File Hippo






    This Website allows users to download free applications from the site itself so users don't have to go to the different websites of each application on their PC. It contains a lot of useful software which are up to date and it also provides older versions of the software.

    The ads are well placed and their colors are not distracting. The categorization of the application installers is well done. The centered layout works well and everything seems neat if the ads are removed. The ads are not that neat, but it is organized and it does not hinder any functionality. The ads are also well placed.



    Bad websites






    This website allows people to download an open prolog but the site itself does not have appeal and its layout makes it hard to read the information displayed. It also lacks a good organizing and it looks like it was not really well thought of unlike the program that can be downloaded from the site.

    http://workbench.cadenhead.org





    This website was made for one of the authors of teach yourself java in 21 days. The website does not have a good design and the layout is basic. It has little appeal. It was obviously made for the file to help the readers and the site does not seem to have any other purpose than that.

    http://www.philippineairlines.com/home/home.jsp






    this website of the Philippine airlines needs improvement. The forms are too small. the color and organization has little appeal. The ads are unattractive and bothersome. The online ticket reservation has bugs. It needs to be HTTPS and better security for the benefit of passengers who orders their ticket online and gives out sensitive information like credit card numbers

    Thursday, June 30, 2011

    Apps that got my attention



    Mobile applications have flooded the internet that allow people to do a task, have entertainment and get informed all from their mobile devices such as smartphones, mobile tablets and other gadgets. There are I apps that I have used when I borrowed some devices and there are those that I remember because it was great while there those that I know because it gave me a bad impression and I wish to avoid those applications

    Great apps to download

    here are the apps I would like to download if I owned the device

    FruitNinja logo.png

    available on the Ipad, Iphone, Ipod, Android, Windows phone 7 and Symbian.

    This was the app that I enjoyed when I borrowed my relatives Ipad. Swiping your finger he touch pad is how I played it. The swiping actually creates a
    slicing motion in order to slice a fruit. I earned extra points by slicing multiple fruits with one slice and it felt nice. The fruits are nicely done and the blades have multiple designs. The look of the game also gets my attention since it looks fun.
    The default game mode obliged me to slice all fruits and avoid the bomb and if I missed 3 fruits, the game ends with my score displayed. In zen mode I sliced as much fruit as I can before the time ran out and it was my favorite mode. The Ipad version also has multiplayer, so I
    was able to play with someone and compete to get the higher score and the gameplay was fair for both of us. I really got into this game and I really had fun with it. Just thinking of it makes me want to play it right now.

    Wave Secure

    This is a security for android devices. This got my attention since I was told that if I am going to get a smartphone I am responsible for it and I need to keep it safe. I felt like I need to remember this kind of app if I plan to get an android device.

    This app protect user data and assures privacy. It also has protection from theft like remote lock down and data recovery features.

    Its user interface also is well done since the features are listed and the icons fit well with the feature like the Wipe now! which is at the last and the icon really warns the user before using that feature.

    An app like this is every useful and it protects the users and
    I wish that it is free or that there are free alternatives. Smartphones are computers also so there really data that should be protected, so an app like this got my attention and I remember it for the right reasons unlike the next apps

    Worst Apps I have seen so far

    This app (iFart) is just useless and it annoys others and it gets corny over time. I never liked this app. This is the first app that comes into my mind when I think of bad apps. It just makes different kinds of fart sounds and do not find that entertaining nor useful.

    iPickuplines


    When I first saw this app, I said "Really, an app to prove how pathetic you are with chicks". Worst of all I find the lines to be corny and my friend prove that they are ineffective. So ineffective that the ads are more convincing, and they are placed well.This app fails to deliver quality and effective pick up lines which really makes it useless. NOTE: Come up with your OWN pick up lines

    photos from:

    Monday, February 28, 2011

    Java GUI

    Here is a set of class that displays a graphic user interface.
    These are multiple classes so you should obtain them all first at
    http://www.mediafire.com/download.php?23vhz263zr696qi

    Actor.java contains the main method
    ---------------------------------------------------------
    import javax.swing.JOptionPane;
    public class Actor {

    static void newOpt(){
    String[] Choices={"BorderLayout","Box Layout","Figures"};
    int i=JOptionPane.showOptionDialog(null, "Pick your Ui", "You choose", JOptionPane.DEFAULT_OPTION , JOptionPane.CLOSED_OPTION, null, Choices, "");
    System.out.println(""+i);
    LaunchFrame LF=new LaunchFrame();
    switch(i){
    case 0: LF.BrdrL(Choices);break;
    case 1: LF.BoxL();break;
    case 2: LF.Figures();break;
    }
    }
    public static void main(String[] args) {
    String[] elems={"JFrame","JLabel","JTextField","JComboBox","JButton","Confirm Dialog","Input Dialog","Message dialog",
    "Password","TextArea","Editor Pane","Menu","Tab","CheckBox & list"};
    LaunchFrame LF=new LaunchFrame();

    int i=JOptionPane.showOptionDialog(null, "Pick your Ui", "You choose", JOptionPane.DEFAULT_OPTION , JOptionPane.CLOSED_OPTION, null, elems, "");
    System.out.println(""+i);
    switch(i){
    case 0: LF.Act1(); break;
    case 1: LF.FrameLabel();break;
    case 2: LF.TxtBx();break;
    case 3: LF.Options();break;
    case 4: LF.Buttons();break;
    case 5: System.out.println("Returned "+JOptionPane.showConfirmDialog(null, elems[5])); break;
    case 6: System.out.println("Returned "+JOptionPane.showInputDialog("Type something"));break;
    case 7: JOptionPane.showMessageDialog(null, elems[7]);break;//returns void
    case 8: LF.Password();break;
    case 9: LF.TxtArea(); break;
    case 10: LF.Ep();break;
    case 11: LF.MenuB(); break;
    case 12: LF.showTab(); break;
    case 13: LF.Listing(elems);break;
    default: newOpt();break;
    }

    }

    }
    ---------------------------------------------------------
    The launch frame has methods that displays the GUI component to be displayed
    ________________________
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    ________________________
    It has the following methods





























    Method codeOutput when called

    public class LaunchFrame{
    public void Act1(){
    JFrame JF=new JFrame("This is a frame"); // Creates a Frame with a titile on the title bar
    JF.setSize(400, 350); //Sets the initial size of the frame
    JF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // The application will close and free up memory space
    JF.setVisible(true); //Makes the Frame visible on the monitor
    }

    public String FileSrch(){
    JFileChooser pick = new JFileChooser();
    int i=pick.showOpenDialog(null);
    if(i==pick.APPROVE_OPTION)
    return pick.getSelectedFile().toString();
    else
    return null;
    }
    A file dialog box

    public void FrameLabel(){
    JFrame JF=new JFrame("This is a frame");
    JF.setSize(400, 350);
    JLabel lbl=new JLabel("Message",JLabel.CENTER); //A JLabel is created stating Message alligned at the center
    JF.add(lbl); //The JFrame will contain the JLabel
    JF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JF.setVisible(true);
    }
    public void TxtBx(){
    JFrame JF=new JFrame("This is a frame");
    JF.setSize(350,300);
    JF.getContentPane().setLayout(new FlowLayout()); //Change the Layouof the Frame
    JF.add(new JLabel("Add text: ")); //JF will now contain a JLabel
    JTextField txtbx=new JTextField(10); //Create a TextField with a specific width
    JF.add(txtbx); //JF will now contain the TextBox
    JF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JF.setVisible(true);
    }
    public void Options(){
    String[] members={"Nickleus","Yao","Jake","Jul"}; //Create an Array of Strings with values
    JFrame JF=new JFrame("Pick an option");
    JF.setSize(250,200);
    JF.getContentPane().setLayout(new FlowLayout());
    JF.add(new JLabel("List of members"));
    JComboBox cb=new JComboBox(); //Create a JCombobox
    cb.addItem("Members"); //Add an Item in the JComboBox
    for(int ctr=0;ctr
    public void Buttons(){
    JFrame JF=new JFrame("Pick an option");
    JF.getContentPane().setLayout(new FlowLayout());
    JF.add(new JLabel("Click"));
    //Set an image to be an Icon
    ImageIcon ic = new ImageIcon("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioi5DYPzAvh4M3L5QVAXIj4A84BmNEdHArTME8f_XE1CGQvlTOF6s7eprDUIHuJ0iyaYzmLVNGjdzFsLeThybqRIgAsTHE0l55rSkDcCBtUwkumn-VRfZMZSGcSAJuHg5SQgQ9P_yYt0o/");
    JButton bt=new JButton("Click me",ic);
    bt.setSize(150, 100); //Set the size of the button
    bt.setToolTipText("You can click this"); //Create a message when mouse hovers on the button
    JF.add(bt);
    JF.pack();
    JF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JF.setVisible(true);
    }
    public void Password(){
    JPasswordField pf=new JPasswordField(10); //Create a password field with a width of 10 pixels
    JFrame JF=new JFrame("pass");
    JF.getContentPane().setLayout(new GridLayout(2,2)); //set the Frame with a GridLayout
    JF.add(new JLabel("User name: "));
    JTextField txtbx=new JTextField(10);
    JF.add(txtbx);
    JF.add(new JLabel("Password: "));
    JF.add(pf);
    JF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JF.pack();
    JF.setVisible(true);
    }

    public void TxtArea(){ //Show a text Area
    JFrame JF=new JFrame("This is a frame");
    JF.setLayout(new FlowLayout());
    JF.add(new JLabel("Add text: "));
    JTextArea txtbx=new JTextArea(10,15); // A text area with the specified text, rows, and columns
    JF.add(txtbx);
    JF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JF.pack(); //Frame authomatically has an initial size base on its contents
    JF.setVisible(true);
    }
    Image

    Thursday, February 3, 2011

    Immigration from C to java[to be finished]
















    In CIn java

    main(){
    /*Code here*/
    }

    public static void main(String[] args) {
    /*Code here*/
    }

    int num;
    printf("Enter a number: ");
    scanf("%d",&num);

    Scanner scn=new Scanner(System.in);
    System.out.print("Enter a number to a variable: ");
    int num=scn.nextInt();
    //end of solution 1

    //Start of solution 2
    int num;
    Scanner scn=new Scanner(System.in);
    System.out.print("Enter a number to a variable: ");
    num=scn.nextInt();

    int x=0;
    printf("x+1= %d\n",x+1);

    int x=0;
    System.out.println("x+1= "+(x+1));

    char word[10];
    printf("Enter a word: ");
    scanf("%s",word);
    String word;
    System.out.print("Enter a word: ");
    word=scn.next();
    //scn is a defined scanner object from the code above

    int ArrInt[5];
    int[] ArrInt=new int[5]

    Sunday, January 2, 2011

    Happy new year

    Its a new year 2011. Hope it for a prosperous and good year. The challenges will come but it can be beaten. My academic life needs improvement. I will turn 18 this year. Oh boy this could be problematic. I think I can apply ads this year so hope to earn money on my own also.