Object Oriented Programming in Java with IntelliJ Part 1

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@dissgo·
0.000 HBD
Object Oriented Programming in Java with IntelliJ Part 1
Hello, everyone!
I'd like to share about what is and how to code object oriented programming in Java language with IntelliJ.
What is Java?
>Java is a computer programming language and computing platform.

What is IntelliJ?
>IntelliJ is an IDE created that make possible for us to code or develop something useful for people.

What is IDE?
>IDE is an Integrated Development Environment that means provide the basic tool for developers to code and test the software. Basicly, it will contain code editor, compiler and debugger.

What is OOP?
>OOP stands for Object Oriented Programming. OOP is a programming concept which applies object concept that the object is consisted of attribute and method.

Now, let's start.
**Step 1**
Install and run IntelliJ which can be downloaded at [here](http://www.jetbrains.com/idea/download/) or directly from the community at [here](http://www.jetbrains.org/display/IJOS/Download). Yes, it's officially built by community. That's why it's called as community edition from the official jetbrains web and it's free.
![1. Setup.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1513955014/glu7vwyemoslfmdyizgf.png)

![1. Setup_2.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1513955080/hwlpvk1g3agqrh67tdnn.png)

You can choose what's disabled plugin or not.
![1. Setup_4.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1513955095/cx7vttapsvqjubfpaxbb.png)

**Step 2**
Create new project to begin.
![1. Setup_5.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1513955164/c64j8mkizt2bmm0b4oi1.png)

Name it as you want to for the project name and package. I recommend the package to be written with lowercase, all of it. Company used to name the package just like their domains, like com.google.android
![2. Create New Project.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1513955196/h49k3twwzwnsniorhehc.png)

**Step 3**
Don't forget to setup your SDK first.
![3. Setup SDK.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1513955542/knvbcqijl7s9olau3pxk.png)

**Step 4**
Create new Java class. This is for the attribute and method inside since the tester class is created by default at Main.java
![4. Create New Java Class_e.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1513955642/yqqtqthnmkbh5fqzso5c.png)

Name it as you want to, but fit your project.
![4. Create New Java Class_2.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1513956046/tjdminpofm5qfjcs821i.png)

**Step 5**
You begin your coding. I'll give an example of the simple class which contains constructor, attribute and method.
![5. Write a Code.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1513956112/buo4ndpt2uxdukzeekez.png)

This coding includes all of attributes. Attributes mean like public variable. So I define Quiz as variable with Double datatype. Datatype represent variant values in the variable.
```
    double Quiz,MidExam,LastExam,Score;
    char Index;
    String Desc;
```

This one is a constructor. Constructor is created to initialize value to the object through parameter. Just like you see below. It initializes Quiz, MidExam and LastExam. It depends on what's method you want to create.
```
    Score(){
        Quiz=0;
        MidExam=0;
        LastExam=0;
    }
```

This one is method. It includes procedure and function. This is what called as procedure. Procedure is a sub program to run several process, but not return the value. Like you see below, I've created `void SetQuiz` to be able to set the value of the Quiz.
```
    void setQuiz(double x){
        Quiz=x;
    }
    void setMidExam(double x){
        MidExam=x;
    }
    void setLastExam(double x){
        LastExam=x;
    }
```

This one is a function. Function is statement that create to run and return the value. Just like you can see below. I've created `double getScore()` to get the score from the value you set for Quiz, MidExam and LastExam before or return the value.
```
    double getScore(){
        Score=0.2*Quiz+0.3*MidExam+0.5*LastExam;
        return Score;
    }
    char getIndex(){
        if(Score>=80 && Score<=100)
            Index='A';
        else if(Score>=68 && Score<=80)
            Index='B';
        else if(Score>=56 && Score<=68)
            Index='C';
        else if(Score>=45 && Score<=56)
            Index='D';
        else
            Index='E';
        return Index;
    }
    String getDesc(){
        if(Index=='A')
            Desc="Very Good";
        else if(Index=='B')
            Desc="Good";
        else if(Index=='C')
            Desc="Not Bad";
        else if(Index=='D')
            Desc="Bad";
        else
            Desc="Very Bad";
        return Desc;
    }
```

Now, get back to the tester class. The example of codes are like these.
![5. Write a Code_2.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1513957210/zdrw9wcev1ltbjrdoy4j.png)

You need to create new Object of your class you created before in this class. That's why you need to create constructor. It will refer as an instance of every object created. Just like you can below. `n` can be anything. You can change to whatever you want to.
```
Score n=new Score();
```
The remain depends on you. Enjoy your coding!

<center>
This is The Final Result.
![8. Finished.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1513959024/zfwykjhis9torgsahk7a.png)
</center>

<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@dissgo/object-oriented-programming-in-java-with-intellij-part-1">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍 , , , , , , , , , , , , , , ,