Saturday 24 November 2012

ABSTRACT CLASSES CONST...........

PROGRAM 7:
      Let us make software to write final result category with an example varying quantity, a concrete method: getRate () and an conclusion method: calculateBill().

//calculate electric invoice for professional and household pans
abstract category plan
{
     //take quantity as secured to access in sub classes
     secured double rate;

     //accept quantity into quantity varying. Since quantity will change
    //depending on strategy, we announce conclusion method
     community conclusion gap getRate();

    //calculate the electric invoice by taking units
     community gap determine (int units)
    {
            System.out.print("bill quantity for "+ models + "units: ");
            system.out.println(rate*units);
     }
}

class professional strategy expands plan
{
     //store household quantity as rs 2.60 per unit
     community gap getRate()
       {
           quantity = 2.60;
         }
}
class calculate
{
    community fixed gap main (string args[])
      {
           //create referrals p to conclusion class
           strategy p;
          //create professional invoice for 250 units
           System.out.println("commercial connection")
           p = new commercialplan(); //use referrals to consult sub class
          //object
          p.getRate();
          p.calculateBill(250);
          //calculate household invoice for 150 units
          System.out.println("Domestic connection: ");
           p = new DomesticPlan();   //use referrals to consult sub class

           // object
           p.getRate();
           p.calculateBill(150);
         }
}


OUTPUT:
c:\>javac determine.java
C\>java calculate

Commercial connection:
Bill quantity for 250 units: 1250.0
Domestic connection:
Bill quantity for 150 units: 390.0

SUMMARY:
       Let us review the points on conclusion class:

    An conclusion category is a category that contains 0 or more conclusion technique.
    An conclusion category can contain example varying and tangible techniques in inclusion to conclusion techniques.
    Subjective category and the conclusion technique should be announce by using the key term 'abstract'
    All the conclusion techniques of the summary category should be applied (body) in its sub sessions.
    If any conclusion techniques is applied then that sub category should be announced s 'abstract'. In this case we cannot make an item to the sub category. We should make another sub category to this sub category and apply the staying conclusion technique there.
    we cannot make an item to conclusion category.
    But we can make a referrals of conclusion category type.
    The referrals of conclusion category can be used to consult things of its subclasses.
    The referrals of conclusion category can not consult individual techniques of its subclasses.
    It is possible to obtain an conclusion category as a sub category from a tangible super category.
    We cannot announce a category as both conclusion and last. For example.

                                     conclusion last category A     //invalid
The key term conclusion symbolizes an partial category  which depends on the sub sessions for its execution. Creating sub category is necessary for conclusion category. last key term stops monetary gift  This means we cannot make sub category to any category the key words conclusion and last are contrary and hence both can not be used at the same time for a category.

No comments:

Post a Comment