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.  <center>  </center> This is the old code from my [post](https://steemit.com/utopian-io/@dissgo/object-oriented-programming-in-java-with-intellij-part-2). We'll start from this. ``` private double Quiz,MidExam,LastExam; public Score(){ Quiz=0; MidExam=0; LastExam=0; } public void setQuiz(double x){ if(x>=0 && x<=100) Quiz=x; } public void setMidExam(double x){ if(x>=0 && x<=100) MidExam=x; } public void setLastExam(double x){ if(x>=0 && x<=100) LastExam=x; } public double getQuiz() { return Quiz; } public double getMidExam() { return MidExam; } public double getLastExam() { return LastExam; } public double getScore(){ return 0.2*Quiz+0.3*MidExam+0.5*LastExam; } ``` The Complete Code on Screenshot  Before we continue to the code, we should know that one of the main features is inheritance in OOP. What is inheritance? >Inheritance is a class that get properties from another class, its attribute and its method. The top class is called as superclass or parent class and the class which is inherited from the top class is called as subclass or extended class. Like in this case, Score is the superclass and Score2 is the subclass. **Step 2** Right-click on the package, then **New>Class** to create the extended class.  Name it as you want to, but to make it easier to remember, don't name randomly or further than the name of the superclass. Like, **Score2**.  New Class created.  Now, let's start the basic to extend the class from inheritance. Change the code in the class before to be like this. Score2 class will be able to use Score class's attributes and methods. ``` public class Score2 extends Score { } ```  Now, let's start coding. I want to add `Exercise` attribute to make the new one for counting the score. ``` private double Exercise; ``` Why `private`? Because to prevent the value to be directly set from another class. You can check my previous post about access level at [here](https://steemit.com/utopian-io/@dissgo/object-oriented-programming-in-java-with-intellij-part-2) Now, create the constructors. This is the constructor without parameter. You can set the value from the class directly itself. e.g : `Exercise=100;` or `Exercise=0;`, then the value will return 100 or 0. ``` public Score2(){ super(); Exercise=0; } ``` This is the constructor with parameter. You can freely set the value when the constructor's referred as an instance of every object in the tester class later. About this code `if(E>=0 && E<=100)`, I need to create the statement right here because it can be an exception or handler if the value is set lower/higher than it's supposed to be, but why don't code like that for `super(Q,M,L);`? Because it has been written in the class itself. So, I just call it here from the superclass. ``` public Score2(double Q, double M, double L, double E){ super(Q,M,L); if(E>=0 && E<=100) Exercise=E; } ``` As always, we need to create getter and setter, but this won't be used if you use constructor with parameter. 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. For example, I will create the getter and setter like this. Why we need to return or make the statement with `this` at `this.Exercise=Exercise;`? Because it declares that the `Exercise` attribute value in this class will be set with `Exercise` parameter. About this code `if(Exercise>=0 && Exercise<=100)`, it's an exception or handler if the value is set lower/higher than it's supposed to be. ``` public void setExercise(double Exercise){ if(Exercise>=0 && Exercise<=100) this.Exercise=Exercise; } public double getExercise() { return this.Exercise; } ``` The last for this class. Create the function which is the same as the superclass, but with additional. `super.getScore()+0.1*Exercise;` means you call the function in the superclass which is created before and in this new class, you add the additional calculation with the new attribute and it becomes one complete function. ``` public double getScore(){ return super.getScore()+0.1*Exercise; } ``` The Complete Code on Screenshot  Now, back to the superclass. You can modify the code to be like this. It's the same thing you've done with new subclass before. ``` private double Quiz,MidExam,LastExam; public Score(){ Quiz=0; MidExam=0; LastExam=0; } public Score(double Q, double M, double L){ if(Q>=0 && Q<=100) Quiz=Q; if(M>=0 && M<=100) MidExam=M; if(L>=0 && L<=100) LastExam=L; } public void setQuiz(double Quiz){ if(Quiz>=0 && Quiz<=100) this.Quiz=Quiz; } public void setMidExam(double MidExam){ if(MidExam>=0 && MidExam<=100) this.MidExam=MidExam; } public void setLastExam(double LastExam){ if(LastExam>=0 && LastExam<=100) this.LastExam=LastExam; } public double getQuiz() { return this.Quiz; } public double getMidExam() { return this.MidExam; } public double getLastExam() { return this.LastExam; } public double getScore(){ return 0.2*Quiz+0.3*MidExam+0.5*LastExam; } ``` The Complete Code on Screenshot  Now, write the code in the tester class like this. As always, create new Object of your class you created before in this tester class first, because It will refer as an instance of every object created. This one if you use the constructor without parameter. ``` Score2 s1; s1=new Score2(); ``` You need to set the value with the setter you created before. For Example, it will be completely like this. ``` Score2 s1; s1=new Score2(); s1.setQuiz(60); s1.setMidExam(80); s1.setLastExam(90); s1.setExercise(100); ``` And, this one if you use the constructor with parameter. You can set directly without using setter. ``` Score2 s2; s2=new Score2(60,80,90,100); ``` <center> **Here is The Final Result**  </center> <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@dissgo/object-oriented-programming-in-java-with-intellij-part-3">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>
author | dissgo | ||||||
---|---|---|---|---|---|---|---|
permlink | object-oriented-programming-in-java-with-intellij-part-3 | ||||||
category | utopian-io | ||||||
json_metadata | {"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":2489216,"name":"intellij-community","full_name":"JetBrains/intellij-community","html_url":"https://github.com/JetBrains/intellij-community","fork":false,"owner":{"login":"JetBrains"}},"pullRequests":[],"platform":"github","type":"tutorials","tags":["utopian-io","tutorial","java","programming","opensource"],"users":["dissgo"],"links":["http://www.jetbrains.com/idea/download/","http://www.jetbrains.org/display/IJOS/Download","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515221273/qmwt1cwbfu5zzb4j2yyz.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515221428/kddiixsjbzcz9ux0skav.png","https://steemit.com/utopian-io/@dissgo/object-oriented-programming-in-java-with-intellij-part-2","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515227768/w1roxbdv7groveeaqslx.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515229948/w3wmiezkcont0dgxnn8s.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515230038/mbxdosepll4oglqwuerx.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515230348/ybwxnahcjiuxj1kl9zhc.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515230446/k6njjg1mwk5hjunjjdep.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515236945/rslquvmlpuklfzvtrcv5.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515236996/e4gxeg8po8xdxlasskid.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515236541/rcgxbpi7wtuph7wt1rw8.png"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1515221273/qmwt1cwbfu5zzb4j2yyz.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515221428/kddiixsjbzcz9ux0skav.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515227768/w1roxbdv7groveeaqslx.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515229948/w3wmiezkcont0dgxnn8s.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515230038/mbxdosepll4oglqwuerx.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515230348/ybwxnahcjiuxj1kl9zhc.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515230446/k6njjg1mwk5hjunjjdep.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515236945/rslquvmlpuklfzvtrcv5.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515236996/e4gxeg8po8xdxlasskid.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1515236541/rcgxbpi7wtuph7wt1rw8.png"],"moderator":{"account":"manishmike10","pending":false,"reviewed":true,"flagged":false}} | ||||||
created | 2018-01-06 11:11:06 | ||||||
last_update | 2018-01-06 17:17:36 | ||||||
depth | 0 | ||||||
children | 7 | ||||||
last_payout | 2018-01-13 11:11:06 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 13.449 HBD | ||||||
curator_payout_value | 5.735 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 8,635 | ||||||
author_reputation | 3,860,675,847,142 | ||||||
root_title | "Object Oriented Programming in Java with IntelliJ Part 3" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 27,500,223 | ||||||
net_rshares | 2,431,179,350,616 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ethandsmith | 0 | 2,057,800,176 | 0.5% | ||
fronttowardenemy | 0 | 182,868,421 | 0.56% | ||
scrooger | 0 | 178,559,348 | 1.71% | ||
derosnec | 0 | 223,557,424 | 1.13% | ||
theleapingkoala | 0 | 158,249,110 | 1.13% | ||
adnanrabbani | 0 | 2,649,283,305 | 50% | ||
bbomber | 0 | 785,023,974 | 50% | ||
jofomaja | 0 | 933,675,362 | 100% | ||
qurator | 0 | 101,736,864,831 | 5.7% | ||
bobdos | 0 | 907,418,042 | 2% | ||
coolguy123 | 0 | 9,746,598,734 | 5% | ||
utopian-io | 0 | 2,310,338,370,413 | 1.62% | ||
steemitstats | 0 | 820,615,221 | 2% | ||
debbey | 0 | 460,466,255 | 100% |
dissgo!! Thank you, your Post. i upvoted.^^
author | iamgun |
---|---|
permlink | 20180107t000444440z |
category | utopian-io |
json_metadata | {} |
created | 2018-01-07 00:04:45 |
last_update | 2018-01-07 00:04:45 |
depth | 1 |
children | 1 |
last_payout | 2018-01-14 00:04:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 43 |
author_reputation | 263,611,044,702 |
root_title | "Object Oriented Programming in Java with IntelliJ Part 3" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 27,641,315 |
net_rshares | 0 |
You're welcome :)
author | dissgo |
---|---|
permlink | re-iamgun-20180107t000444440z-20180110t093337790z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-01-10 09:33:39 |
last_update | 2018-01-10 09:33:39 |
depth | 2 |
children | 0 |
last_payout | 2018-01-17 09:33:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 17 |
author_reputation | 3,860,675,847,142 |
root_title | "Object Oriented Programming in Java with IntelliJ Part 3" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 28,454,325 |
net_rshares | 0 |
Your contribution cannot be approved yet. See the [Utopian Rules](https://utopian.io/rules). Please edit your contribution to reapply for approval. `We could use the code from my previous post.` * It would be better if you specified those codes in this post. You may edit your post [here](https://utopian.io/utopian-io/@dissgo/object-oriented-programming-in-java-with-intellij-part-3), as shown below:  You can contact us on [Discord](https://discord.gg/UCvqCsx). **[[utopian-moderator]](https://utopian.io/moderators)**
author | manishmike10 |
---|---|
permlink | re-dissgo-object-oriented-programming-in-java-with-intellij-part-3-20180106t143141714z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-06 14:31:51 |
last_update | 2018-01-06 14:31:51 |
depth | 1 |
children | 1 |
last_payout | 2018-01-13 14:31:51 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 615 |
author_reputation | 20,399,732,899,016 |
root_title | "Object Oriented Programming in Java with IntelliJ Part 3" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 27,536,872 |
net_rshares | 0 |
Done @manishmike10. You can review again.
author | dissgo |
---|---|
permlink | re-manishmike10-re-dissgo-object-oriented-programming-in-java-with-intellij-part-3-20180106t161946591z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"users":["manishmike10"],"app":"steemit/0.1"} |
created | 2018-01-06 16:19:48 |
last_update | 2018-01-06 16:19:48 |
depth | 2 |
children | 0 |
last_payout | 2018-01-13 16:19:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 41 |
author_reputation | 3,860,675,847,142 |
root_title | "Object Oriented Programming in Java with IntelliJ Part 3" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 27,559,218 |
net_rshares | 0 |
Thank you for the contribution. It has been approved. You can contact us on [Discord](https://discord.gg/UCvqCsx). **[[utopian-moderator]](https://utopian.io/moderators)**
author | manishmike10 |
---|---|
permlink | re-dissgo-object-oriented-programming-in-java-with-intellij-part-3-20180106t171738201z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-06 17:17:42 |
last_update | 2018-01-06 17:17:42 |
depth | 1 |
children | 1 |
last_payout | 2018-01-13 17:17:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 172 |
author_reputation | 20,399,732,899,016 |
root_title | "Object Oriented Programming in Java with IntelliJ Part 3" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 27,570,707 |
net_rshares | 0 |
Thanks for approval @manishmike10
author | dissgo |
---|---|
permlink | re-manishmike10-re-dissgo-object-oriented-programming-in-java-with-intellij-part-3-20180106t183148065z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-06 18:31:51 |
last_update | 2018-01-06 18:31:51 |
depth | 2 |
children | 0 |
last_payout | 2018-01-13 18:31:51 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 33 |
author_reputation | 3,860,675,847,142 |
root_title | "Object Oriented Programming in Java with IntelliJ Part 3" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 27,584,678 |
net_rshares | 0 |
### 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. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER! - <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a> - <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a> - Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a> [](https://steemit.com/~witnesses) **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**
author | utopian-io |
---|---|
permlink | re-dissgo-object-oriented-programming-in-java-with-intellij-part-3-20180107t160336840z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-07 16:03:36 |
last_update | 2018-01-07 16:03:36 |
depth | 1 |
children | 0 |
last_payout | 2018-01-14 16:03:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,504 |
author_reputation | 152,955,367,999,756 |
root_title | "Object Oriented Programming in Java with IntelliJ Part 3" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 27,791,570 |
net_rshares | 104,443,821 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
superdoctor | 0 | 104,443,821 | 100% |