So I was wondering what if Aam Aadmi Party was implemented in Obeject Oriented way(AAP in OOP), thus I am writing here snippets of the code which I wrote in 5-10 minutes and would open source it, so that you guys can extend this effort :P.
I am starting here with class AamAadmiParty:
package indian.politics; //Version 0.1 //Author: Puneet Singh public class AamAadmiParty extends Congress implements Socialism, Communism, Populism, Mobocracy{ //Created Kejriwal using singleton design pattern, can't create so honest man again public Kejriwal kej = Kejriwal.getInstance(); public void getDonations(int money){ this.putItInWebsite(money); } public void putItInWebsite(int money) { System.out.println(money); } private boolean doKhulaseAndRunAway(boolean isFormedGovernmentWithCongress) { if(!isFormedGovernmentWithCongress) { isFormedGovernmentWithCongress = this.madePeopleFoolEnough(); return doKhulaseAndRunAway(isFormedGovernmentWithCongress); } else { return true; } } public void before2014() { kej.honesty(); } private void after2014() { indian.politics.Congress i = null;//null as in the number if seats expected in 2014 mergeWithCongress(i); } private void mergeWithCongress(Congress c) { System.out.println("We are against communal forces!!"); } private boolean madePeopleFoolEnough() { return false; } }
And the other class would be Kejriwal implemented using Singleton Pattern:package indian.politics; public class Kejriwal { private static volatile Kejriwal instance = null; private ()Kejriwal { } public static Kejriwal ()getInstance { if (instance == null) { synchronized (Kejriwal.class) { if (instance == null) { instance = new ();Kejriwal}}} return instance;} protected void honesty() { System.out.println("I am honest, every one else is dalal"); honesty();//infinite until stackoverflow}}
You can get started with the complete source code using this link https://code.google.com/p/aapinoop
I hope you are familiar with SVN.

No comments:
Post a Comment