Object Oriented Programming in Java with IntelliJ Part 2

in #utopian-io8 years ago (edited)

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.
First, Install and run IntelliJ which can be downloaded at here or directly from the community at here. 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
1. Setup_2.png

We could use the code from my previous post.
1. Old.png

Before we continue to the code, we should know about the access level or access modifiers in Java.
There are four access modifiers, package-private, protected, public and private.
Package-Private is the access modifier by default. It means the member in the same package can be accessed each other, but it can't be known by the subclass. It's the access modifier without defining with public, private or protected. I give the example for the attribute.

double Quiz,MidExam,LastExam

Protected is the access modifier which the member in the same package can be accessed each other and it can be known by the subclass. It means if you want to access the subclass from another class, you can extend the class of another class. I give the example for the attribute.

protected double Quiz,MidExam,LastExam

Public is the access modifier which the member can be accessed publicly or visible to all of class. I give the example for the attribute.

public double Quiz,MidExam,LastExam

Private is the access modifier which the member can be accessed only itself in the class. I give the example for the attribute.

private double Quiz,MidExam,LastExam

From the previous of my post, we modify it a little. Make your attribute private to make the value can't be directly set.
2. Private.png

You can see what happens on the tester class. It can't access, because the class is private, even though it's in the same package.
2. Private_2.png

Now, we need to make the public setter and getter.
What is setter?

Setter is the method to modify or set the value of the variable.

What is getter?

Getter is the method to get or view the value of the variable.

Modify all of it just like the code below. About this code if(x>=0 && x<=100), it's an exception or handler if the value is set lower/higher than it's supposed to be.

    public void setQuiz(double x){
        if(x>=0 && x<=100)
            Quiz=x;
    }
    public double getQuiz() {
        return Quiz;
    }

3. Getter_2.png

Then, run the tester again. Don't forget to change to getQuiz and the others as well, too, to make it get your value, then return it.

        Score n=new Score();
        n.setQuiz(60);
        System.out.println("Quiz        : "+n.getQuiz());

3. Getter_3.png


Here is The Final Result.
9. Result Normal.png

Object Oriented Programming in Java with IntelliJ Part 1


Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

love java programming, but is not easy to execute.

Yeah, love :D

This is really captivating. and informative

Thank you.

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Thanks for approval @syedumair

Hey @dissgo I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.04
TRX 0.33
JST 0.083
BTC 64134.32
ETH 1731.02
USDT 1.00
SBD 0.41