ElaKiri Programmer's Club

tery123

Well-known member
  • Feb 25, 2011
    6,031
    177
    63
    34
    මචන්ලා uml වල මේකේ මේ තියෙන association එක නැතුව ඔය +DISPLAYMEMBER() METHOD එක concreate method එකක් කරලා ඔය association නැතුව දාන්න පුළුවන් නේද??? +display() එක abstract තියෙලා..

    16ly78n.jpg


    මේක කලේ මෙන්න මේක improve කරන්න...

    22x7ux.jpg


    මෙන්න මේ විදියට...

    rrt8iu.jpg
     

    tery123

    Well-known member
  • Feb 25, 2011
    6,031
    177
    63
    34
    PHP:
    class polygan{
    public void set(int l,int w){
    
    	protected int length=l;
    	protected int width=w;
    
    	}
    }
    class rectangle extends polygan{
    
    public int recAria(){
    
    	return width*length;
    	}
    }
    
    class triangle extends polygan{
    
    	public int triAria(){
    
    		return width*length/2;
    		}
    }
    class inheritance{
    
    	public static void main(String args[]){
    
    		rectangle rec=new rectangle();
    		rec.set(10,20);
    		System.out.println("aria of the rectangle is : " + rec.recAria());
    
    		triangle tri=new ttriangle();
    		tri.set(10,50);
    		System.out.println("aria of the triangle is : " + tri.triAria());
    		}
    }
    ai bun meke protected danna denne naththe:dull::dull::dull:
     
    Last edited:

    DooA

    Well-known member
  • Jun 22, 2011
    5,202
    773
    113
    ආගිය අතක් නැත
    PHP:
    class polygan{
    public void set(int l,int w){
    
    	protected int length=l;
    	protected int width=w;
    
    	}
    }
    class rectangle extends polygan{
    
    public int recAria(){
    
    	return width*length;
    	}
    }
    
    class triangle extends polygan{
    
    	public int triAria(){
    
    		return width*length/2;
    		}
    }
    class inheritance{
    
    	public static void main(String args[]){
    
    		rectangle rec=new rectangle();
    		rec.set(10,20);
    		System.out.println("aria of the rectangle is : " + rec.recAria());
    
    		triangle tri=new ttriangle();
    		tri.set(10,50);
    		System.out.println("aria of the triangle is : " + tri.triAria());
    		}
    }
    ai bun meke protected danna denne naththe:dull::dull::dull:


    Access modifier danna puluwan field variable walata vitharai.

    E kiwwe clz eka athule but method walin eliye thiyena ewata
     

    tery123

    Well-known member
  • Feb 25, 2011
    6,031
    177
    63
    34
    PHP:
    public class SingletonDemo {
    private static SingletonDemo singletonObject;
    private SingletonDemo() {
    // Optional Code
    }
    public static SingletonDemo getSingletonObject(){
    if (singletonObject == null){
    singletonObject = new SingletonDemo();
    }
    return singletonObject;
    }
    }

    mokakda bun meke karala thiyenne:dull::dull::dull::dull:
     

    MihiCherub

    Well-known member
  • Sep 14, 2009
    18,861
    1
    9,627
    113
    Gampaha
    PHP:
    public class SingletonDemo {
    private static SingletonDemo singletonObject;
    private SingletonDemo() {
    // Optional Code
    }
    public static SingletonDemo getSingletonObject(){
    if (singletonObject == null){
    singletonObject = new SingletonDemo();
    }
    return singletonObject;
    }
    }
    mokakda bun meke karala thiyenne:dull::dull::dull::dull:
    Design Patterns.. eka Object ekai hadanne.. :cool:
     

    DooA

    Well-known member
  • Jun 22, 2011
    5,202
    773
    113
    ආගිය අතක් නැත
    PHP:
    public class SingletonDemo {
    private static SingletonDemo singletonObject;
    private SingletonDemo() {
    // Optional Code
    }
    public static SingletonDemo getSingletonObject(){
    if (singletonObject == null){
    singletonObject = new SingletonDemo();
    }
    return singletonObject;
    }
    }

    mokakda bun meke karala thiyenne:dull::dull::dull::dull:





    Singleton design pattern eka.

    Ubata ba oya clz eke instance hadanna. New SingleDemo(); kiyala

    Karanne puluwan SingleDemo.getInstance(); kiyala. Ethakota hama welawema return karanne ekama instance eka. Ube mulu program ekema oya clz eke eka instance ekak vitharai thiyenne.
     

    tery123

    Well-known member
  • Feb 25, 2011
    6,031
    177
    63
    34
    Singleton design pattern eka.

    Ubata ba oya clz eke instance hadanna. New SingleDemo(); kiyala

    Karanne puluwan SingleDemo.getInstance(); kiyala. Ethakota hama welawema return karanne ekama instance eka. Ube mulu program ekema oya clz eke eka instance ekak vitharai thiyenne.

    meka saralawa pennanan widiyak nadda patern eka use nokara?????

    A class has a single constructor which is only visible within the class. What purpose might this class serve?
    (5 marks)
    e) Write some code which is an example of the situation described in part (d)

    menna mekai prashne:dull::dull::dull::dull:
     

    DooA

    Well-known member
  • Jun 22, 2011
    5,202
    773
    113
    ආගිය අතක් නැත
    meka saralawa pennanan widiyak nadda patern eka use nokara?????

    A class has a single constructor which is only visible within the class. What purpose might this class serve?
    (5 marks)
    e) Write some code which is an example of the situation described in part (d)

    menna mekai prashne:dull::dull::dull::dull:

    ප්‍රශ්නෙට උත්තරේ නම් ඕක තමයි මචං. උන් ඉල්ලන්නේ singalton pattern එක.

    With the Singleton design pattern you can:

    Ensure that only one instance of a class is created

    Provide a global point of access to the object

    Allow multiple instances in the future without affecting a singleton class's clients
     

    tery123

    Well-known member
  • Feb 25, 2011
    6,031
    177
    63
    34
    ප්‍රශ්නෙට උත්තරේ නම් ඕක තමයි මචං. උන් ඉල්ලන්නේ singalton pattern එක.

    With the Singleton design pattern you can:

    Ensure that only one instance of a class is created

    Provide a global point of access to the object

    Allow multiple instances in the future without affecting a singleton class's clients

    machan pe patterns gana igena ganna pothak ehema nadda????:dull::dull::dull:
     

    sw7x

    Well-known member
  • Nov 12, 2007
    11,114
    2,296
    113
    මචන්ලා මට web browser එක හා... එහි ඇති JS API Interfaces ගැන ඉගෙන ගන්න ඔන.....
    දන්න කෙනෙක් ඉන්නවනම් ලින්ක් එකක් හරි කමක් නැ දෙන්න