egg jam ple chai..
java ma dim hoi..c++ teti aunna..Object Oriented ko concept nai bujhne ta honi..hoina?
set ra get method chai afai bujha hoi..alchi lago ke...
public class Saman
{
String samanName;
int samanQty;
/**regular constructor**/
public Saman(String sName, String sQty)
{
samanName = sName;
samanQty = sQty;
}
/** copy constructor **/
public Saman(Saman s) /** copy constructor always takes Class Object as parameter
{
this.samanName = s.getSamanName();
this.samanQty = s.getSamanQty();
/** Alternate methods
* Call regular constructor
* return(Saman (s.getSamanName(),s.getSamanQty());
}
public void testCopyConstruct()
{
Saman chauChau1 = new Saman("waiwai",10); //calling regular constructor
Saman chauChau2 = new(chauChau1); //this will copy all the attributes of chauchau1
//to chauchau 2
chauChau2.setSamanName("rara"); //aba rara ni 10 wotai raicha bhane..kina feri 10 bhanera
//initialize garnu bhanera...tyo copy use garya hoi
}
}
aba yo program milyo milena chai thaha chaina hera....but concept chai testai ho..
aba bujhena bhane..gimme 5 more bucks..feri bujhaidimla..