Methods in programming

Methods in programming

Waa maxay #Method?

Su'aashan waxa in badan i soo waydiisa dhalinta si gaara kuwa daneeya #programmingka. Waayahay!

Haddaba i soo raac. Waxa aad furatay Bank Account si aad hawlaha maalin la ah ugu isticmaasho.

Marka aad Bankiga furanayso waxa la gu waydiiyaa caddaymo sida ID,SHAHAADO ama LIISAN kuwan oo lagu kaydiyo Banka si mustaqbalka hawlaha adiga ku khuseeya loogu adeegsado.

Marka Account ka laguu fasaxo, waxa aad samaysaa hawlo badan sida DHIGASHADA lacagta, LABIXIDA lacagta

iyo DIRIDA lacagta aad saaxiibaddaa u xawisho.

Haddaba BankAccount marka programmingka la joogo waa #Class. ID ga, SHAHAADADA iyo LIISAN kuna waa #Variables(attributes/properties) kuwan oo xogta lagu kaydiyo halka hawl qabadka DHIGASHADA, LABIXIDDA iyo DIRIDU yihiin #Methods.

Waxa aynu halkan ka garan karnaa hawl qabadka/shaqada ayaa waxa loo yaqaanaa Method. Tan oo ka dhigan

shaqo kastaa waxa ay leedahay hawl gaara tusaale ahaan DHIGASHADA iyo DIRIDU waa laba hawlood oo aad u kala durugsan. Sidaa darteen ayaa waxa la yidhaa "Methods are used to perform certain/specific actions".

Dhanka kale haddii aynu ka eegno QOF ku waxa uu sameeyaa afcaal badan sida CUNIDA, SOCOSHADA, HADLIDA; haddaba ficiladan marka programmingka la joogo waxa loo yaqaan #METHODS(functions).

public class BankAccount {

 private Long acc;

 private String type;

 public void deposit(double amount){

 }

 public double withdraw(double amount){

}

Waxa xiiso leh in marka aad lacag BANk DHIGANAYSO aanad wax ba kala so noqonin; waayo lacagtii aad sidatay waad dhigatay sidaa darteed adiga oo faro madhan ayaad ka soo laabanaysaa. Haddaba markan MEHTOD/action waxa loo yaqaan "non-value return type".

Halka marka aad lacag la soo BAXAYSO aad adiga oo jeebku kuu buuxo ka soo laabato BANKA ,loolz. Tan ayaa ka dhigan in "Method/action ku soo celinayo qiime", waxaana loogu yeedhaa "value return type".

Tusaaleha xagga sare ku qoran "deposit()" waa "non-value return type" sidaa awgeed waxa lagu calaamadiyay "void/madhan" , halka "withdraw()" ka tahay "value return type", laguna asteeyey " double/lacag".

Waan ogsoonahay in aanad wax badan iga fahmin se waxa aan rajaynayaa in wuxuun kaaga soo duxeen.

Maxa kuu biniixay?

Page follow sii dhaha.