WHAT'S NEW?
Loading...

Object Oriented in Java with basic inheritance example

Design based on OOP approach with Person and Faculty classes. Person class be implemented to PersonDemo and Person class be inherited to Faculty class. InheritanceDemo will perform the action to display the output. We all know that OOP is the best practice when designing a software that developers/programmers can benefits the reuse of existing codes, re-write the same functions for different situations, ease in software maintenance, and a lot more.

Person
/** * Created by joannnou on 22 Mar 2017. */public class Person {
    private String firstName,lastName,middleName,gender;
    private int age;

    public Person(String fName, String lName, String mName, String gender, int age){
        this.firstName = fName;
        this.lastName = lName;
        this.middleName = mName;
        this.gender = gender;
        this.age = age;
    }
    public Person(){
        this.firstName = "No firstname yet!";
        this.lastName = "No lastnname yet!";
        this.middleName ="No middlename yet!";
        this.gender = "No gender yet";
        this.age = 0;
    }
    public Person(String fName, String lName, String mName){
        this.firstName = fName;
        this.lastName = lName;
        this.middleName = mName;
    }
    //set firstname    public void setFirstName(String fName){
        this.firstName = fName;
    }
    //get firstname    public String getFirstName(){
        return firstName;
    }
    //set lastname    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
    //get lastname    public String getLastName() {
        return lastName;
    }
    //set middlename    public void setMiddleName(String mName){
        this.middleName = mName;
    }
    //get middlename    public String getMiddleName(){
        return middleName;
    }
    //set gender      public void setGender(String gender) {
        this.gender = gender;
    }
    //get gender    public String getGender() {
        return gender;
    }
    //get name format    public String fullName(){
        return "Name:" + firstName + " " + middleName + ". " + lastName;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    @Override    public String toString() {
        return "Person{" +
                "firstName='" + firstName + '\'' +
                ", lastName='" + lastName + '\'' +
                ", middleName='" + middleName +'\''+
                ", gender='" + gender + '\'' +
                ", age=" + age +
                '}';
    }
}

PersonDemo
/** * Created by joannnou on 22 Mar 2017. */
import java.util.Scanner;
public class PersonDemo { static Scanner console = new Scanner(System.in); public static void main(String[]args){ Person p = new Person(); String fName,lName,mName,gender; int age; System.out.println("Enter your firstname:"); fName = console.nextLine(); p.setFirstName(fName); System.out.println("Enter your middlename:"); mName = console.nextLine(); p.setMiddleName(mName); System.out.println("Enter your lastname:"); lName = console.nextLine(); p.setLastName(lName); System.out.println("Enter your gender"); gender = console.nextLine(); p.setGender(gender); System.out.println("Enter your age:"); age = console.nextInt(); p.setAge(age); //display all detail information
        System.out.println(p.toString());
        //display name only        
        System.out.println(p.fullName());
    }
}
Faculty

/** * Created by joannnou on 22 Mar 2017. */

 public class Faculty extends Person {
    private String position;

    public Faculty(){
        super();
        position = "No Position Yet!";
    }
    public Faculty(String facFirstName,String facMiddleName, String facLastName, String facGender, int facAge, String facPosition){
        super(facFirstName,facMiddleName,facLastName,facGender,facAge);
        this.position = facPosition;
    }
    public void setPosition(String facultyPosition){
        this.position = facultyPosition;
    }
    public String getPosition(){
        return position;
    }
    public String toStringFac(){
        //toString method came from Person class        
        //I rename toStringFac for Faculty class        
        return toString() + "\nPosition:" + position;
    }
}
InheritanceDemo 

/** * Created by joannnou on 22 Mar 2017. */

    public class InheritanceDemo {
   
    public static void main(String []arg){

        Faculty initialName = new Faculty();
        Faculty assignName = new Faculty("Joannou","H.",
                "Fegarido","Male",29,"Faculty");

        //display no name yet!        
        //get the default value from Person class        
        System.out.println(initialName.toStringFac());
        System.out.println("--------------------------------");
        //display assigned name        
        System.out.println(assignName.toStringFac());
    }
}


Output:

PersonDemo produced the following output in Line 36:
Person{firstName='Joannou', lastName='Fegarido', middleName='H', gender='Male', age=29}
Name:Joannou H. Fegarido

InheritanceDemo produced the following output:
Person{firstName='No firstname yet!', lastName='No lastnname yet!', middleName='No middlename yet!', gender='No gender yet', age=0}
Position:No Position Yet!
--------------------------------
Person{firstName='Joannou', lastName='H.', middleName='Fegarido', gender='Male', age=29}
Position:Faculty

LAN Based Configuration, Installation process, and Software Version - Queuing System

Welcome to this post! My version of Queuing System I made, I will discuss the installation process, software version needed, LAN configuration, and more…  I’ll give all duties and responsibility to modify the program suited on your need as you receive the purchased source code from me.  Let me discuss one by one what the use of program is so that you will be able to understand the flow of the program. However, let’s have identified the requirements in order to run the program.

Please download the following Software Version:

*Visual Studio 2010 Ultimate
*mysql-connector-net-6.4.6
* mysql-connector-net-6.4.4
*mysql-5.5.17-win32
*mysql-workbench-gpl-5.2.35.1-win32

Note:  Make sure you downloaded all software versions. (Noticed: we have 2 MySql connecter versions, please download the 2 version).

At the end of this, you will be able to:

      A.  Install all software requirements to run the program
      B. Setup and configure database (MySql Workbench) connection. (import/export)
      C. Make modification. (You may change transaction names, labels, and more) Let me know if you            can’t understand how to make it.
      D. Create Portable Application.
   E. Setup LAN based configuration (IP Address) in MySQL Workbench with multiple users    (Counters/Cashiers/Teller), Screen Display, and Client/Customer Transaction Display)

A.      Installation Process:

             1. Make sure you already install Visual Studio 2010 Ultimate (Professional can be use also)
             2. Next, install mysql-connector-net-6.4.6 version (latest version must install 1st or else a dialog              message box display a message to remove the older version in order to install the latesT
                 version.
             3. Then, install mysql-connector-net-6.4.4. (Note: I install this 2 version because one of my                      applications requires 6.4.6 version, but if you’re going to develop soon with mysql connector,               use only one version so that later you don’t get mad why your program have an error.
             4. Next, install mysql-5.5.17-win32. All are all in default settings. When requires password, put               12345 just number only.
             5. Lastly, install mysql-workbench-gpl-5.2.35.1-win32.

Note: If you encountered error while installing mysql-5.5.17, may be the port you trying to connect was already used (The error occurred when Xampp or any apache uses the ports). To address, use available ports). In my case, I uninstall them all not to conflict my work.

B.  Setup and Configure MySQL Workbench. (Manage Import/Export)










C. Now, you can make some modification on your program.

D. Create Portable Application

To create Portable Application will not require you to install Visual Studio 2010 Ultimate on every device. You only need to install mysql-connector-net versions in every device every time to run the program. Refer to the installation process in number 3 stated above (make sure to install 2 versions of it). 

In your program application, just locate the bin à debug. Create a folder and copy all files in debug folder to your created folder. Since the debug folder have not yet DLL files which required the program to run.



In figure above, the only files available in your debug folder. However, when you add other references all files are going here. If files doesn’t appear, you may manually copy and paste to this folder.

This are files needed to run the portable files. Sometimes, it requires the .Net Framework version to run this. Don’t worry, you can download it and choose the right version to run the program.


The DLL (Data Link Library) file format will only added. However, notice I added some DLL files that doesn’t used it, it Okay! It’s better to keep them all than missing other DLL files. If you can’t find the DLL files, you can download it:________    after you download you copy them all and paste to debug folder or in your created folder.

Your application is now ready. No need to install, just simply copy the folder and save on your drive. To run the program, double click the name of the program (Note: Application Type).
However, it doesn’t end. How about your database? Since your program requires database to start the program. Let’s start setup our database using workbench.


E. Setup LAN based configuration (IP Address) in MySQL Workbench with multiple users.

Network Setup



To setup database server, you can use one of your PC as your server to host your database. In this example, I used PC 5 as my server. Make sure to open it first the server and follow the other PC’s. Why? Every PC requires database connectivity everytime to open it. I recommend to have it separate PC, may be you can put it on your SERVER that run 27/7. The PC you used as your Server must have MySQL Workbench intalled and Connector as what you did before and don’t forget to import the database file. In your server, you don’t need to install Visual Studio 2010. Just follow the installation process from 2 – 5.

Now, we are going to assign IP address. If you already have existing IP address on your network, you can use it. However, if you want to configure from the scratch. Assign each IP address in each PC. (used Stright – Through cable) .


Finally, you already setup the network. Next, in your debug folder or in your own folder where you copy the content of your debug folder. Right click the file and open the XML file in notepad.



Take a look at the highlighted, server=localhost refers to the local machine. However, since we are going to network our system. Change localhost to 192.168.0.1 that point to the server where the database is located. Do this in all other application (Display, Counter, Client).

In your Server PC where the database was located. Search MySQL Command Line in ALL Programs


Once you open it, when the command line requires you a password, type: 12345


Type: grand all privileges on dbcpc. * to root@’%’ identified by ‘12345’;
Note: dbcpc refers to your database files and 12345 is the password of your database. Grant ALL grant the users to access file to your database.

To run your program, just simply copy the portable files on every PC’s. For display for example, copy the portable file for display PC, the same in Counter and Client. If you have multiple Clients, just simply copy and paste then double click the application program. If you can’t understand well the whole process of this tutorial, feel free to contact me to setup your network via TeamViewer or Skype.