HELP REQUIRED ON HOW TO AVOID 'IF ELSE' BY USING CTE

Hi
I've written a script (snippet below) that returns the correct results but I'd like to use a CTE instead as I would like to avoid 'IF ELSE' and also so I can query the results later in the procedure.
Any help would be greatly appreciated.
L
/*ReportingDate variable for testing*/
DECLARE @ReportingDate date = '13-apr-14'
DECLARE @IsWeek1 int
DECLARE @IsWeek53 int
SELECT @IsWeek53 = CASE WHEN ReportingWeekOfYear = 53 THEN 1 ELSE 0 END
FROM d_Date
WHERE DateValue = CAST(DATEADD(dd,-1,@ReportingDate) as date)
/*LAST YEAR*/
BEGIN
IF @IsWeek53 = 1 --If the @ReportingDate falls in Week 53 generate LY's Week 52 equivalent
SELECT a.DateValue OneDayAgo_LY
,DayNameFull
,a.ReportingDayOfWeek
,a.ReportingWeekOfYearName
,a.ReportingMonthOfYearName
,a.ReportingYear_int
,a.ReportingWeekOfMonthName
FROM d_Date a
JOIN (SELECT ReportingYear_int, ReportingWeekOfYear, ReportingDayOfWeek FROM d_Date WHERE DateValue = CAST(DATEADD(dd,-1,@ReportingDate) as date)) b
ON a.ReportingYear_int = b.ReportingYear_int - 1
AND a.ReportingWeekOfYear = b.ReportingWeekOfYear - 1
AND a.ReportingDayOfWeek = b.ReportingDayOfWeek
ELSE
SELECT a.DateValue OneDayAgo_LY
,DayNameFull
,a.ReportingDayOfWeek
,a.ReportingWeekOfYearName
,a.ReportingMonthOfYearName
,a.ReportingYear_int
,a.ReportingWeekOfMonthName
FROM d_Date a
JOIN (SELECT ReportingYear_int, ReportingWeekOfYear, ReportingDayOfWeek FROM d_Date WHERE DateValue = CAST(DATEADD(dd,-1,@ReportingDate) as date)) b
ON a.ReportingYear_int = b.ReportingYear_int - 1
AND a.ReportingWeekOfYear = b.ReportingWeekOfYear
AND a.ReportingDayOfWeek = b.ReportingDayOfWeek
END

Why do you need CTE?
Isnt this enough?
DECLARE @ReportingDate date = '13-apr-14'
/*LAST YEAR*/
SELECT a.DateValue OneDayAgo_LY
,DayNameFull
,a.ReportingDayOfWeek
,a.ReportingWeekOfYearName
,a.ReportingMonthOfYearName
,a.ReportingYear_int
,a.ReportingWeekOfMonthName
FROM d_Date a
JOIN (SELECT ReportingYear_int, ReportingWeekOfYear, ReportingDayOfWeek FROM d_Date WHERE DateValue = CAST(DATEADD(dd,-1,@ReportingDate) as date)) b
ON a.ReportingYear_int = b.ReportingYear_int - 1
AND a.ReportingWeekOfYear = b.ReportingWeekOfYear - CASE WHEN ReportingWeekOfYear = 53 THEN 1 ELSE 0 END
AND a.ReportingDayOfWeek = b.ReportingDayOfWeekWHERE DateValue = CAST(DATEADD(dd,-1,@ReportingDate) as date)
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • How to avoid data repetation when using select statements with innerjoin

    how to avoid data repetation when using select statements with innerjoin.
    thanks in advance,
    satheesh

    you can use a query like this...
      SELECT DISTINCT
             frg~prc_group1                  "Product Group 1
             frg~prc_group2                  "Product Group 2
             frg~prc_group3                  "Product Group 3
             frg~prc_group4                  "Product Group 4
             frg~prc_group5                  "Product Group 5
             prc~product_id                  "Product ID
             txt~short_text                  "Product Description
    UP TO 10 ROWS
    INTO TABLE l_i_data
    FROM
    Joining CRMM_PR_SALESG and
    COMM_PR_FRG_ROD
    crmm_pr_salesg AS frg
    INNER JOIN comm_pr_frg_rod AS prd
    ON frgfrg_guid = prdfragment_guid
    Joining COMM_PRODUCT and
    COMM_PR_FRG_ROD
    INNER JOIN comm_product AS prc
    ON prdproduct_guid = prcproduct_guid
    Joining COMM_PRSHTEXT and
    COMM_PR_FRG_ROD
    INNER JOIN comm_prshtext AS txt
    ON prdproduct_guid = txtproduct_guid
    WHERE frg~prc_group1 IN r_zprc_group1
       AND frg~prc_group2 IN r_zprc_group2
       AND frg~prc_group3 IN r_zprc_group3
       AND frg~prc_group4 IN r_zprc_group4
       AND frg~prc_group5 IN r_zprc_group5.
    reward it it helps
    Edited by: Apan Kumar Motilal on Jun 24, 2008 1:57 PM

  • Help required. How to print Header Text in customized PO ?

    Hi experts,
    Please help me go forward with this.
    I'm using a ZMEDRUCK & standard printing program.
    I have put my code here. Pls go through it and help me what has to be corrected here.
    PROGRAM  ZMEDRUCK_SUBP2.
    FORM fetch_table_data TABLES in_tab STRUCTURE itcsy
                                 out_tab STRUCTURE itcsy.
      TABLES EKKO.
      DATA: BEGIN OF header OCCURS 0,
              ld_txt1(163),
              ld_txt2(163),
              ld_txt3(163),
            END OF header.
      DATA: li_lines LIKE STANDARD TABLE OF tline WITH HEADER LINE,
            ID like THEAD-TDID,
            TNAME LIKE THEAD-TDNAME,
            TDOBJECT like THEAD-TDOBJECT.
      DATA  HTEXT LIKE EKKO-EBELN.
      DATA f_lines TYPE P.
    *  HTEXT = EKKO-EBELN.
      READ TABLE in_tab WITH KEY EKKO-EBELN.
      if sy-subrc = 0.
      TNAME = in_tab-value.
      ENDIF.
    *TNAME = EKKO-EBELN.
    *CONCATENATE EKPO-ebeln EKPO-ebelp INTO v_item_text.
    *MOVE v_head_text to HNAME.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input         = TNAME
    IMPORTING
       OUTPUT        = TNAME
    CALL FUNCTION 'READ_TEXT'
      EXPORTING
    *   CLIENT                        = SY-MANDT
        id                            = 'F01'
        language                      = 'E'
        name                          = TNAME
        object                        = 'EKKO'
    *   ARCHIVE_HANDLE                = 0
    *   LOCAL_CAT                     = ' '
    * IMPORTING
    *   HEADER                        = TNAME
      tables
        lines                         = li_lines
    EXCEPTIONS
       ID                            = 1
       LANGUAGE                      = 2
       NAME                          = 3
       NOT_FOUND                     = 4
       OBJECT                        = 5
       REFERENCE_CHECK               = 6
    *   WRONG_ACCESS_TO_ARCHIVE       = 7
    *   OTHERS                        = 8
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    READ TABLE li_lines INDEX 1.
      IF sy-subrc = 0.
        header-ld_txt1 = li_lines-tdline.
      ENDIF.
    DESCRIBE TABLE li_lines LINES f_lines.
      data: lstr type String,
            lstr1 type string,
            lstr2 type string,
            lstr3 type string,
            lstr4 type string.
      read table li_lines index 1.
        lstr = li_lines.
        condense lstr.
        clear li_lines.
      read table li_lines index 2.
        lstr1 = li_lines.
        condense lstr.
        clear li_lines.
      read table li_lines index 3.
        lstr2 = li_lines.
        condense lstr.
        clear li_lines.
      if f_lines GT 3.
        read table li_lines index 4.
        lstr3 = li_lines.
        condense lstr.
        clear li_lines.
      read table li_lines index 5.
        lstr4 = li_lines.
        condense lstr.
        clear li_lines.
        endif.
      DATA: v_text type text.
          CONCATENATE lstr1 lstr2 lstr3 lstr4 into v_text separated by ' '.
          CLEAR out_tab.
      READ TABLE out_tab WITH KEY name = 'TNAME'.
        out_tab-value = v_text.
        MODIFY out_tab INDEX sy-tabix.
    ENDFORM.
    And my script is :
    /:PERFORM FETCH_TABLE_DATA IN PROGRAM ZMEDRUCK_SUBP2
    /:USING &EKKO-EBELN&
    /:CHANGING &TNAME&
    /: ENDPERFORM
    IL RECEIVED FROM M/S     &TNAME&

    Hi,
    Use this Function module 'READ_TEXT'
    T_lines contains the header text, you can loop it and display it in sap script
    Function module to read the header text
      CALL FUNCTION 'READ_TEXT'
        EXPORTING
          client                  = sy-mandt
          id                      = 'F01'
          language                = sy-langu
          name                    = ekko-ebeln
          object                  =  ekko
        TABLES
          lines                   = t_lines
        EXCEPTIONS
          id                      = 1
          language                = 2
          name                    = 3
          not_found               = 4
          object                  = 5
          reference_check         = 6
          wrong_access_to_archive = 7
          OTHERS                  = 8.
    Regards
    Krishna

  • Required Validation: How to avoid Annoying Validation Message

    Hi friends,
    I have a situation where i don't want to see the validation until i click commit button. I found out through some googling that if SkipValidation= true is set on pageDef file then you won't have that issue. And yes it seems working for form/sub-form case but i am dealing with attribute in the table:
    When i insert new row in the af:table or clear value of an existing required attribute then the validation error popup and won't let me go anyway. And according to Andrejus blog at http://andrejusb.blogspot.com/2012/09/what-to-do-when-adf-editable-table.html , we can achieve this using immediate= true for the table attribute itself. But I am kind of worried that i will skip some adf life cycle doing that. I was wondering if there is some other may be out of box way like skipValidation for table as well.
    Thanks
    JDEV: 11.1.1.6.0

    Hi Timo,
    Sorry not helpful at all, i have already mentioned in my question that, skipValidation = true approach won't work for editable table only for form/sub-form and only working solution i have it setting table attribute to immediate, but i was looking to see if any other approach is there which is better then immediate = true, since i will skip some life cycle if i do so.
    Thanks

  • How to avoid displaying date,time using Enhancement point.

    Hi friends,
    i have to work on the standard report.
    stadard report displays date,time ,reportname on the top of the page. my requirement is not to display date ,time,reportname.
    they have used the following code,
    WRITE text-001 TO m_line+d_offset(4). " Time
    WRITE sy-timlo USING EDIT MASK '__:__:__' TO m_line+d_offset(08).
    WRITE text-002 TO m_line+d_offset(05). " Date
    WRITE sy-datlo DD/MM/YYYY TO m_line+d_offset(10).
    BY using Enhancement point how to achieve my task.
    kindly help me

    Post Author: jsanzone
    CA Forum: WebIntelligence Reporting
    basham,
    You didn't mention which type of DBMS you are using (i.e. Oracle, MS SQL, MySQL, etc), but in a nutshell using MS SQL here is the principle.  Your time that is recorded in the records is dependent upon a setting in your RDBMS.  For instance, the RDBMS can use the machine time (which would most likely be local time), or it can use the machine time with an offset (to accomodate GMT, for instance).  GMT is factored differently based upon your time zone (and time of year, i.e. DST or EST, etc).  I'm on the east coast so right now my offset is GMT - 5, so if my time right now is 1457, then GMT is 1957.  To get SQL to compute an offset you must take the number of hours to offset and divide by 24 (24 hours in a day) and add that to the record in the database.  For instance, to get GMT right now I would use:
    select cast(getdate()5/24. as char(12))rtrim(convert(char(12),getdate()5/24.,8))' GMT'
    Hope this helps.  If you're on Oracle, then the mathematical principles remain the same, just the formatting will be different.

  • How to avoid the anonymous login using  RIMLoginModule?

    Hi everybody,
    we have configured the RIMLoginModule on a WebAS to enable SSO on Blackberry devices. The login module works as expected when the Rim-device-email header parameter is available in the request. But without this header an automatic login occures using the anonymous user. How should we configure the module or the security provider to avoid this behaviour?
    Note: if we lock the anonymous user, the problem is solved. But, we want to keep the anonymous user unlocked and configure the module to use a basic authentication when the Rim-device-email pamaeter is missed in the request.
    regards
    Edited by: Michael Kinder on Nov 7, 2008 9:20 AM

    Sean
    You need to set up the anonymous user (via Admin). Add him to the
    defaultRole and then you can assign the channels to the anonymous user as
    per normal.
    Cheers
    Sean Xue wrote:
    I setup a domain only have anonymous authenticate module and I can't add
    the channels that I like to be displayed to the login page. Is anybody
    know how to do that. Thanks.

  • Help...How to Play Video and Auido using windows media player in developer forms?

    I am using the Windows NT workstation and Oracle Forms6i, I want to know how to use window media player in oracle forms? I have insert an OLE object and add Windows media player as an control object, but I don't know how to play the audio and video.
    I always have this error...why?? How can I solve this??
    FRM-41344: OLE object not defined for VIDEO in the current record.
    Cause:     An empty OLE container is defined.
    Action:     Define an OLE object to reside in the OLE container.
    Level:     20
    Type:     Error
    This is my final year project, anyone can help me?
    Thanks a lot!!!

    UKNightOwl wrote:
    ... providing the computer has Windows Media Player installed, ...
    ... This saves you having to bother with portable/travel speakers,
    Mains lead for the computer is a bit of a problem on the bus though!

  • Help !!  how to redeploy only an ejb using weblogic.Deployer ?

    Hi everyone, how to redeploy only one ejb (not the entire application) using weblogic.Deployer ? I executed the following command and getting wiered error !!! :
    java weblogic.Deployer -adminurl http://myadmin:7000 -username system -password weblogic -name myApp.ear -activate -targets testEJB.jar@jytServer -source myApp.ear
    I am getting the following error :
    weblogic.management.ApplicationException:
    [J2EE:160043]Missing deployment descriptor "META-INF/application.xml" at myApp.ear".
    The ear file very much contains the application.xml under META-INF directory and in the application.xml, there is an entry for myBean.jar.
    However if i try the following command, it will redeploy the EJB but it will deploy it as a separate application :
    java weblogic.Deployer -adminurl http://myadmin:10720 -username system -password weblogic -targets jytServer deploy testEJB.jar
    But I want to redeploly it as a part of .ear application.
    I would highly appreicate your help. (assume that admin console access is denied and i will have to use weblogic.Deployer to redeploy).
    thanks,
    jyothi

    Where do I specify the order of deployment? I have 2 EJB jar files and Web module, the order need to be Web module first, 2 EJB then EAR. In WebSphere it is defined in Deployment.xml file, where do I define Deployment.xml in WebLogic

  • Help needed !  How to find out 'XML Difference' using XDK

    I'm using oracle.xml.differ.XMLDiff.
    I have set XML files.
    Then calling generateXSLFile("somefile")
    While running facing :
    Exception in thread "main" java.lang.NullPointerException
    at oracle.xml.differ.XMLDiff.generateXSL(XMLDiff.java:383)
    at oracle.xml.differ.XMLDiff.generateXSLFile(XMLDiff.java:330)
    at XMLDiffTest.main(XMLDiffTest.java:38)
    Same prob if I use setDocuments(xd1,xd2) ....
    What is the way out ?
    Does anyone have any sample code ?
    TYI
    Kaniska

    To compare XML documents with the XMLDiff class.
    -Add /lib/xml.jar and /lib/xmlparserv2.jar to the Classpath.
    -Parse the two documents to be compared with the DOMParser.
        DOMParser parser=new DOMParser();
                 parser.parse("file://c:/xmlFile1.xml");
    XMLDocument document1=parser.getDocument();
    XMLDocument document2;-Create an object of type XMLDiff
    XMLDiff xmlDiff=new XMLDiff(); -Set the documents to be compared.
    xmlDiff.setDocuments(document1, document2);-Compare the XML documents.
    boolean diff=xmlDiff.diff();If diff is 'true', the documents are different.
    -Generate the XSLT for the differences between the XML documents.
    xmlDiff.generateXSLFile("diff.xslt");

  • Please reply:how to avoid extra trailing spaces while using cursor sharing

    i am using cursor sharing with FORCE or SIMILAR.
    what is the solution to avoid extra trailing spaces without any java code change.
    do we have any option in oracle to avoid extra trailing spaces during the query processing ?
    I am using Oracle 10g
    CURSOR SHARING is a feature in which multiple sql statements
    which are same will have a shared cursor (in the library cache) for an oracle session,
    i.e, the first three steps of the sql processing (hard parse, soft parse, optimization)
    will be done only the first time that kind of statement is executed.
    There are two ways in which similar SQL statements with different condition values can be made to "SHARE" cursor during execution:
    1. Writing SQLs with Bind Variables: SQLs having no hard coded literals in them
    For e.g., the query below
    SELECT node.emp_name AS configid
    FROM emp node
    WHERE emp_no = :1
    AND dept_no =
    DECODE (SUBSTR (:2, 1, 3),
    :3, :4,
    (SELECT MAX (dept_no)
    FROM emp
    WHERE emp_no = :5 AND dept_no <= :6)
    AND node.dept_type = :7
    ORDER BY node.emp_name
    Here all the variables are dynamically bound during the execution. The ":X" represents BIND Variable and the actual values are bound to the SQL only at the 4th step of the execution of the SQL.
    In applications: The queries written with "?" as bind variables will be converted into ":X" and are sqls with Bind Variables.
    2. The CURSOR_SHARING parameter: Only Useful for SQL statements containing literals:
    For eg., the query below:
    SELECT node.emp_name AS configid
    FROM emp node
    WHERE emp_no = 'H200'
    AND dept_no =
    DECODE (SUBSTR (:1, 1, 3),
    'PLN', :2,
    (SELECT MAX (dept_no)
    FROM emp
    WHERE emp_no = :3 AND dept_no <= :4)
    AND node.dept_type = :5
    ORDER BY node.emp_name
    In the query above, there are two hard coded literals H200 , PLN. In this case when the same SQL executed with different values like (H2003 , PLN), oracle will create a new cursor for this statement and all the first three steps ( hard & soft parse and optimization plan) needs to be done again.
    This can be avoided by changing the CURSOR_SHARING parameter which can be set to any of three values:
    1. EXACT: Causes the mechanism not be used, i.e. no cursor sharing for statements with different literals. This is the default value.
    2. FORCE: Causes unconditional sharing of SQL statements that only differ in literals.
    3. SIMILAR: Causes cursor sharing to take place when this is known not to have any impact on optimization.
    So, FORCE and SIMILAR values of the parameter will be helping in cursor sharing and improve the performance of the SQLs having literals.
    But here the problem arises if we use the FORCE and SIMILAR other than EXACT.
    alter session set cursor_sharing ='EXACT'
    select 1 from dual;
    '1'
    1
    alter session set curson_sharing='FORCE'
    select 2 from dual;
    '2'
    2
    alter session set curson_sharing='SIMILAR'
    select 3 from dual;
    '3'
    3
    So, this will give extra trailing spaces in when we retrieve from java method and any
    further java processing based on the hardcoded literal values will fail. this needs lot of
    effort in remodifying the existing millions of lines of code.
    My question is i have to use cursor sharing with FORCE or SIMILAR and can't we do the trimming
    from the oracle query processing level ?
    please help me on this ?
    Message was edited by:
    Leeladhar
    Message was edited by:
    Leeladhar

    Please reply to this thread
    How to avoid extr trailing spaces using Cursor sharing opton FORCE, SIMILAR

  • Avoid an alert with using self-signed certificate

    Hi
    I want to publish a free product and I would like to use a free self-signed certificate
    But during installing, the Adobe Exstension Manager shows an alert
    Where is a way how to avoid this alert with using a self-signed certificate (I generated certificate with help of Adobe Exchange Packager) or I should only use a paid code-signed certificate?
    Best regards
    Maxim

    As I understund, "Show warning when instaling..." this option available only for end user in Exstantion manager, right? It means there is no way how to switch off this warning if I use ucf.jar tool for packing ZPX and an user uses default setting on this end. When, only one way is left - to buy a payed certificate, even for free product. Correct?

  • How to handle  user exits while using BAPI

    HI experts can any one help me on how to handle user exits while using BAPI. Do we need to handle it explicitly or standard  BAPI will take care of it??.
    Regards,
    Hari Krishna

    If you have added some fields using append structures for screen enhancements, then you have to use appropriate user exits to fill these data while calling BAPI.  Some BAPIs have EXTENSION structures to fill the custom data which can be processed using user exists or enhancements.
    Regards
    Vinod

  • How to get STPOV structure values using BOM number and Plant number

    hello All,
    could you please help me out
    'How to get  STPOV structure values using BOM number and Plant number'
    is there any function module where can i give input as bom and plant number .
    waiting for your response.
    regards
    srinivas

    I did a quick where-used lookup in SE11 on the structure STPOV in function module interfaces and came up with the following:
    Function Module                             Short Description                                          
    CK_F_TOTALCOST_COMPUTE                                                                      
    CS_ALT_SELECT_COUPLED_PRODUCT                                                               
    CS_WHERE_USED_CLA                Bills of material; class use                               
    CS_WHERE_USED_CLA_ANY        Bills of material; direct class use or via other class     
    CS_WHERE_USED_CLA_VIA_CLA        Bills of material; class use via classes                   
    CS_WHERE_USED_COP                                                                           
    CS_WHERE_USED_DOC                Bills of material; document use                            
    CS_WHERE_USED_DOC_ANY:Bills of material; direct and (indirectly) document use via
    CS_WHERE_USED_DOC_VIA_CLA        Bills of material; document use via classes                
    CS_WHERE_USED_KNO                Bills of material; use object dependency                   
    CS_WHERE_USED_MAT                Bills of material; where-used list                         
    CS_WHERE_USED_MAT_ANY:Bills of material; where-used list as article or class item
    CS_WHERE_USED_MAT_VIA_CLA        Bills of material; where-used list via classes             
    EXIT_SAPMC29M_001                BOM; Article Where-Used List   
    It appears that this structure is primarily used for where-used look-ups for components within the BOM.  I don't know if any of these are what you're in need of.
    Hope this helps,
    Mark Schwendinger

  • How to find all the infotypes used for LSO?

    Folks,
    Can anyone help me on how to find the related infotypes used for LSO?
    Thank
    S

    Hi,
    In addition to puneet's information:
    Training and Event Mgmt  infotypes:
        Prices (Infotype 1021)
        Availability Indicators (Infotype 1023)
        Capacity (Infotype 1024)
        Depreciation Meter/Validity (Infotype 1025)
        Business Event Info (Infotype 1026)
        Site-Dependent Additional Info (Infotype 1027)
        Address (Infotype 1028)
        Business Event Type Info (Infotype 1029)
        Procedure (Infotype 1030)
        Mail Address (Infotype 1032)
        Name Format (Infotype 1034)
        Schedule (Infotype 1035)
        Costs (Infotype 1036)
        Billing/Allocation Info (Infotype 1037)
        Business Event Blocks (Infotype 1041)
        Schedule Model (Infotype 1042)
        Demand (Infotype 1060)
        Web Link (Infotype 1061)
        Knowledge Link (Infotype 1062)
        Business Event Group Info (Infotype 1063)
    Thanks,
    Anil.G

  • How to avoid multiple if else using design patterns.

    Hi,
    Which design patterns is used to avoid lot of if else in our code . Say for example if the user press 1 the out put should be one, if he press 2 it should be two like this upto 10. So we need to include lot of if-else part. How to avoid the multiple if else using design patter for this scenario. I can't find the solution for this problem can you guys help me?.

    I'm too lazy to read a whole text book, but the first google link provides a code sample which made me laugh.
    http://www.refactoring.com/catalog/replaceConditionalWithPolymorphism.html
      double getSpeed() {
        switch (_type) {
          case EUROPEAN:
            return getBaseSpeed();
          case AFRICAN:
            return getBaseSpeed() - getLoadFactor() * _numberOfCoconuts;
          case NORWEGIAN_BLUE:
            return (_isNailed) ? 0 : getBaseSpeed(_voltage);
        throw new RuntimeException ("Should be unreachable");
      }My implementation of The Bridge Over The Parrot Shop
    package forums;
    import java.util.Random;
    abstract class Bird {
      private static final Random random = new Random();
      abstract double getAirSpeed();
      public double getBaseSpeed() {
        return randomDouble(18.96);
      protected static double randomDouble(double max) {
        return random.nextDouble() * max;
      protected static int randomInt(int max) {
        return random.nextInt(max);
    class EuropeanSwallow extends Bird {
      double getAirSpeed() {
        return getBaseSpeed();
    class AfricanSwallow extends Bird {
      private int _numberOfCoconuts;
      public AfricanSwallow() {
        this(randomInt(4));
      public AfricanSwallow(int numberOfCoconuts) {
        _numberOfCoconuts = numberOfCoconuts;
      double getAirSpeed() {
        return getBaseSpeed() - getLoadFactor() * _numberOfCoconuts;
      public double getLoadFactor() {
        return randomDouble(3.12);
    class NorwegianBlue extends Bird {
      private boolean _isNailed;
      private double _voltage;
      public NorwegianBlue() {
        this(randomInt(10)<2, randomDouble(12.0));
      public NorwegianBlue(boolean isNailed, double voltage) {
        _isNailed = isNailed;
        _voltage = voltage;
      double getAirSpeed() {
        return _isNailed ? 0 : getBaseSpeed(_voltage);
      double getBaseSpeed(double voltage) {
        return getBaseSpeed() * (1+(voltage/Math.PI));
    public class AirSpeedTest
      public static void main(String[] args)
        System.out.println("EUROPEAN: "+new EuropeanSwallow().getAirSpeed());
        System.out.println("AFRICAN: "+new AfricanSwallow().getAirSpeed());
        System.out.println("NORWEGIAN_BLUE: "+new NorwegianBlue().getAirSpeed());
    }... and the requisite background for the uninitiated [NORWEGIAN_BLUE|http://www.youtube.com/watch?v=4vuW6tQ0218] and [EUROPEAN v AFRICAN|http://www.youtube.com/watch?v=4b4bGAoVR7g].
    You have to know these things when you're a King you know.
    Cheers. Keith.

Maybe you are looking for

  • How can I display all content (graphics)

    On Skynet (United airlines employee website), when I try to look at the "seat selection" window, it displayes only numbers, it does not display a graphic of the cabin (seats). How can I display all content?

  • Error while creating Shopping cart in EBuy

    Hi, We are working on SRM 5.0 - Classic scenario. While creating a SC, we are getting an error mentioned below - Error when processing your request - Note *The following error text was processed in the system SRD : Syntax error in program SAPLBBP_PD_

  • Oracle Function in JDBC Adapter

    Dear All Can we execute an oracle fucntion using receiver jdbc adapter? if yes then what should be the structure I have gone through following links but the soluiotn is not clear Using PI - Calling a Function in Oracle Regards Sourabh

  • Forced *^$$#% Line Returns!

    I have suffered this problem for too long now. It is in just about everything I do, web design, blog editors what have you. I would guess 90% of the time I do not want a line return after I type a word or phrase. Back in my FRONTPAGE days I got aroun

  • Manager in mate becasue all method get  and not method set???

    In mate they use this technology what I do not still have clear is that because always in the managers methods go only get and not set????? Because?? [Bindable (event="sqPhotoDBCountChanged")]         public function get sqPhotoDBCount():uint {