How to calculate the circumference of a circle based on the following Circle class?

I have the following sealed Cirlce class
public sealed class Circle
private double radius;
public double Calculate(Func<double, double> op)
return op(radius);
I need to calculate the circumference of a (an arbitrary) circle based on this class without modifying the class.  Here is what I tried that is not working:
Circle cir = new Circle();
double circ = 2 * Math.PI * cir.Calculate(5, 5);
How can I calculate a circumference of a circle based on this scenario?
Rich P

Ok, let's clarify:
Facts:
1. The radius-field is private, and you can't set it via a public member like a method/property.
2. You don't want to change the class, but the radius
That means in other words you want to change a private field from outside of the class, which is not nice, but possible:
Circle cir = new Circle();
var field = cir.GetType().GetField("radius",BindingFlags.Instance|BindingFlags.NonPublic);
field.SetValue(cir, 5);
double circ = cir.Calculate((radius) => 2 * Math.PI * radius);
Ha, and now, did I manage to pass the skills test question? ;-)
Thomas Claudius Huber
"If you can't make your app run faster, make it at least look & feel extremly fast"
My latest Pluralsight-course:
Windows Store Apps - Data Binding in Depth
twitter: @thomasclaudiush
homepage: www.thomasclaudiushuber.com
author of: ultimate Windows Store Apps handbook |
ultimate WPF handbook |
ultimate Silverlight handbook

Similar Messages

  • How to execute the query for a block based on the parameter

    Hi All,
    Good evening.
    i have requirement where i need to display the data in one block based on the selected items.
    the scenario is like this...there are 2 LOV's and one apply button and one external region on the form.
    so when u select the lov values and click on apply button the query should execute based on this 2 lov values.
    i am not getting how to achieve this..i am very new to oracle forms..
    Please Help..
    Thanks
    Bharat
    please help..it is urgent..
    thanks
    bharat
    Edited by: Bharat on Jan 31, 2012 5:19 AM

    Bharat wrote:
    Hi All,
    Good evening.
    i have requirement where i need to display the data in one block based on the selected items.
    the scenario is like this...there are 2 LOV's and one apply button and one external region on the form.
    so when u select the lov values and click on apply button the query should execute based on this 2 lov values.
    i am not getting how to achieve this..i am very new to oracle forms..Another way you can do this. Create a lov and don't assign it to any column just one return item (should be id).
    Now create a button may be your "apply button" write two trigger when-button-press and when-mouse-click.
    at When -Button-Press trigger, change the block state to 'ENTER-QUERY' and at when-mouse-click show the LOV and then write execute_query.
    Hope this will help you.
    If someone's response is helpful or correct, please mark it accordingly.

  • Changing the color of the column in a JTable based on the selection (mouse)

    Hi,
    I want to change the color of all the cells in a column based on the mouse clicked event.
    I have managed to select the entire column. And, even, I have found a working example in the internet. But I don't understand why in my case it doesn't work.
    This is the code (an inner class for a TableCellRenderer):
    class MCTableCellRenderer extends JLabel implements TableCellRenderer {
              private static final long serialVersionUID = 1L;
              @Override
              public Component getTableCellRendererComponent(JTable table,
                        Object value, boolean isSelected, boolean hasFocus, int row,
                        int column) {
                   setFont(table.getFont());
                   if(value instanceof Double){
                        setHorizontalAlignment(SwingConstants.RIGHT);
                        DecimalFormat numberFormat = (DecimalFormat) NumberFormat.getInstance();
                        numberFormat.applyPattern("#######.#");
                        String val = numberFormat.format(value);
                        setText(val);
                   if(isSelected){
                        setBackground(Color.RED);
                        System.out.println("is selected");
                   else{
                        setBackground(Color.BLACK);
                        System.out.println("is not selected");
                   return this;
        }I have set opacity to true for the contentPane, but without any result.
    Any advice will be very apreciated.

    Problem solved.
    My Renderer should have extended the abstract class DefaultTableCellRenderer.
    class MCTableCellRenderer extends DefaultTableCellRenderer {

  • Process flow for the Mid-year Status Changes based upon the Qualifying Even

    Hi Experts,
    I'm looking some information for the process flow for the Mid-year Status Changes based upon the Qualifying Events. Basically, I need to know, what would be the impact of these changes on various info types (Via IT0014 - Deduction changes & so forth) and the things that needs to be considered during it's Configuration and the things that needs to be checked due to the occurrence of the change. I would greatly appreciate any kind of help/document.
    Thanks a bunch in advance,
    Thanks,
    Exertive.

    Hello guys,
    Can anyone has any kind of input on this? Basically, I need to know the procees for Mid-year status changes based upon Qualified events. Any kind of help is greatly appreciated.
    Thanks,
    Exertive.

  • SAP Bex: How to calculate formula variable, without dragging corresponding date in the row

    Hi Experts,
    In my requirement, we should not do any changes in the BW system. I need to create a Bex query on the existing Info-set, KPI need to be calculated from the date objects.
    e.g
    Delivery date - Order date - which has been done with the formula variable in the bex, I'm getting exact value. the  problem is if I'm not dragging the Delivery date or order date in the Bex ROW, its not populating value. I'm expecting consolidated value for a month.
    It has an impact in the BOBJ system. since i'm not getting consolidated value, the number of data which is coming in BOBJ system is very huge. Hence doing calculating in the bobj will affect performance.
    Regards
    Vijaykumar

    Hi,
    i think your calculating the value form Delivery date - Order date.
    if you drag the Delivery date - Order date object to rows it will give values.
    Thanks,
    Phani.

  • How to get the total number of occurrences based on the value of a column.

    Hello everyone,
    This is the first time that I will ask question here on your forum but has been following several threads ever since. I guess that now is my turn to ask a question. So anyway here is the thing, I have a query that should return count the number of rows depending on the value of SLOT. Something like this:
    WIPDATAVALUE          SLOT             N            M
    1-2                   TRALTEST43S1     1            3
    1-2                   TRALTEST43S1     2            3
    3                     TRALTEST43S1     3            3
    4-6                   TRALTEST43S2     1            4
    4-6                   TRALTEST43S2     2            4
    4-6                   TRALTEST43S2     3            4
    7                     TRALTEST43S2     4            4-----
    As you can see above, on the SLOT TRALTEST43S1, there are three occurrences so M (Total number of occurrences) should be three and that column N should count it. Same goes with the SLOT TRALTEST43S2. This is the query that I have so far:
    SELECT DISTINCT
    WIPDATAVALUE, SLOT
    , LEVEL AS n
    , m
    FROM
      SELECT
        WIPDATAVALUE
        , SLOT
        , (dulo - una) + 1 AS m
      FROM
        SELECT
          WIPDATAVALUE
          , SLOT
          , CASE WHEN INSTR(wipdatavalue, '-') = 0 THEN wipdatavalue ELSE SUBSTR(wipdatavalue, 1, INSTR(wipdatavalue, '-')-1) END AS una
          , CASE WHEN INSTR(wipdatavalue, '-') = 0 THEN wipdatavalue ELSE SUBSTR(wipdatavalue, INSTR(wipdatavalue, '-') + 1) END AS dulo
        FROM trprinting
        WHERE (containername = :lotID OR SLOT= :lotID) AND WIPDATAVALUE LIKE :wip
    ) CONNECT BY LEVEL <= m
    ORDER BY wipdatavalue;And that it results to something like this:
    WIPDATAVALUE          SLOT             N            M
    1-2                   TRALTEST43S1     1            2
    1-2                   TRALTEST43S1     2            2
    3                     TRALTEST43S1     1            1
    4-6                   TRALTEST43S2     1            3
    4-6                   TRALTEST43S2     2            3
    4-6                   TRALTEST43S2     3            3
    7                     TRALTEST43S2     1            1-----
    I think that my current query is basing its M and N results on WIPDATAVALUE and not the SLOT that is why I get the wrong output. I have also tried to use the WITH Statement and it works well but unfortunately, our system cant accept subquery factoring.
    I know you guys will be helping out because you are all awesome. Thanks everyone
    Edited by: 1001275 on Apr 19, 2013 8:07 PM
    Edited by: 1001275 on Apr 19, 2013 8:18 PM

    Hi,
    Sorry, it's still not clear what you want.
    Are you saying that, given this table:
    CREATE TABLE trprinting
      WIPDATAVALUE       VARCHAR2(255)
    , SLOT               VARCHAR2(255)
    INSERT INTO trprinting (wipdatavalue, slot) VALUES ('1-2',  'TRALTEST43S1');
    INSERT INTO trprinting (wipdatavalue, slot) VALUES ('3',    'TRALTEST43S1');
    INSERT INTO trprinting (wipdatavalue, slot) VALUES ('4-6',  'TRALTEST43S2');
    INSERT INTO trprinting (wipdatavalue, slot) VALUES ('7',    'TRALTEST43S2');you want to produce this output:
    WIPDATAVALUE SLOT                     N          M
    1-2          TRALTEST43S1             1          3
    1-2          TRALTEST43S1             2          3
    3            TRALTEST43S1             3          3
    4-6          TRALTEST43S2             1          4
    4-6          TRALTEST43S2             2          4
    4-6          TRALTEST43S2             3          4
    7            TRALTEST43S2             4          4? If so, here's one way:
    WITH     got_numbers     AS
         SELECT     wipdatavalue
         ,     slot
         ,     TO_NUMBER ( SUBSTR ( wipdatavalue
                               , 1
                           , INSTR ( wipdatavalue || '-'
                                ) - 1
                     )          AS low_number
         ,     TO_NUMBER ( SUBSTR ( wipdatavalue
                               , 1 + INSTR ( wipdatavalue
                     )          AS high_number
         FROM     trprinting
    SELECT       wipdatavalue
    ,       slot
    ,       ROW_NUMBER () OVER ( PARTITION BY  slot
                                 ORDER BY          low_number
                        )                    AS n
    ,       COUNT (*)     OVER ( PARTITION BY  slot )     AS m
    FROM       got_numbers
    CONNECT BY     LEVEL               <= high_number + 1 - low_number
         AND     low_number          = PRIOR low_number
         AND     PRIOR SYS_GUID ()      IS NOT NULL
    ORDER BY  low_number
    ,            n
    ;Much of the complexity here is caused by storing 2 numbers in 1 VARCHAR2 column, wipdatavalue. Relational databases work best when there is no more than 1 item in any given column of any given row. This is so basic to datbase design that it is called First Normal Form. Also, numbers belong in NUMBER columns, not VARCHAR2. If you stored your data like that in the fist place, then you wouldn't need the sub-query I called got_numbers, which is about 60% of the code above. (That could be reduced by replacing SUSTR and INSTR with the less efficient REGEGP_SUBSTR.)

  • How does one create a form that redirects based on the input of the form?

    What I am trying to do is have a form with one input. Lets call it "ID".
    There are multiple pages that the form can direct to depending on the ID the user inputs.
    All of the page extentions end with the ID. For example www.page.com/0001.html.
    So I want the user to put in "0001" then submit. The user will then be directed to page www.page.com/0001 if they put in an invalid ID user will be directed to "ID not found" page.
    Any help would be much apreciated!! Thanks.

    on form.php put a form like this:
    <form method="POST" action="redirect.php">
    <input type="text" name="id" value="" /><br />
    <input type="submit" value="redirect" />
    </form>
    on redirect.php put this:
    <?php
    if (isset($_POST['id'])) {
         header ('Location: http://yoursite.com/'.$_POST['id'].'html');
         exit;
    }else{
         header ('Location: http://yoursite.com/form.php');
         exit;
    ?>
    best,
    Shocker

  • How to set condition in choose from list based on the combo selection

    Dear Members,
         i have a requirement to filter the item based on the itemgroup. After choosing the itemgroup in the dropdown list i have to filter the item for the particular group in the choose from the list.since i have tried in the combo select it doesnt work out for me.any body can suggest me is it doable. if so pls tell me the work around.
    My coding is as follows..
    Case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT
    if pval.itemUID="Cmb"
                                objChooseCollection = objForm.ChooseFromLists
                                objChooseFromList = objChooseCollection.Item("CFL1")
                                objConditions = objChooseFromList.GetConditions()
                                objcondition = objConditions.Add()
                                objcondition.Alias = "itmsgrpcod"
                                objcondition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL
                                objcondition.CondVal = Form.items.item("Cmb").specific.selected.value
                                objChooseFromList.SetConditions(objConditions)
    End if
    With Regards,
    jai.
    Edited by: JaiShankarRaman on Dec 23, 2009 10:47 AM

    Hello,
    Following is a code sample which I am using:
            Dim oForm As SAPbouiCOM.Form
            Dim oMatrix As SAPbouiCOM.Matrix
            Dim oChooseFromList As SAPbouiCOM.ChooseFromList
            Dim oConditions As SAPbouiCOM.Conditions
            Dim oCondition As SAPbouiCOM.Condition
            Dim CodeType As Integer
            Try
                oForm = oPayOn.SBO_Application.Forms.GetForm(CflEvent.FormTypeEx, CflEvent.FormTypeCount)
                oMatrix = oForm.Items.Item("AC_MATRIX").Specific
                oChooseFromList = oForm.ChooseFromLists.Item("ACC_CFL1")
                CodeType = oMatrix.Columns.Item("AC_MC00").Cells.Item(CflEvent.Row).Specific.Selected.Value
                oConditions = oChooseFromList.GetConditions
                If oConditions.Count > 0 Then
                    oCondition = oConditions.Item(0)
                Else
                    oCondition = oConditions.Add
                End If
                oCondition.Alias = "U_CodeType"
                oCondition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL
                oCondition.CondVal = CodeType
                oChooseFromList.SetConditions(oConditions)
            Catch ex As Exception
                'oPayOn.SBO_Application.SetStatusBarMessage(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Medium, True)
            End Try
        End Sub
    I am calling this in the CFL event - before action. So when the user clicks on CFL button - but before it opens - this code is called and the condition is applied. Here AC_MC00 is a combo column in a matrix.
    Regards
    Rahul Jain

  • How to re-size a overflow text frame based on the text length?

    Hi ..
    Is it possible to re-size a overflow text frame based on the text length?

    Hello,
    Please refer to forum post : http://forums.adobe.com/message/4828489#4828489
    Regards,
    Sachin

  • I have the exclamation point symbol next to podcasts that don't meet the criteria for said symbol based on the FAQ

    When I'm looking through and trying to manage my Podcast library within iTunes, I see the exclamation point symbol next to several. My first issue is the fact that there are many that have this symbol that I only wanted a few episodes and not a subscription. How can I fix this problem?
    My second issue is that for many of the podcasts with the exclamation point symbol, they don't fit the criteria based on what's in the Symbol FAQ, which states that there are too many unplayed episodes so new episodes won't download. For the podcasts in question, this is not the case, as all episodes have been listened to. What can be done to fix this problem?
    My third issue is the fact that when I DO play a podcast on my iPod Touch (4th Gen), I don't use the app (can't stand it), then go to sync it with the computer, these episodes are shown as having already been played PRIOR to the actual syncing happening. So, when I go to do the ACTUAL sync, the play count is off. Right now, I have to manually reset the play count so that the episodes that I listened to on my iPod Touch only show one play in the library count, not two or in some cases, three. How can I fix this problem?
    I have the most current version of iTunes and use Windows 7 64-bit.
    Thanks for ANY help!

    Try this Support Article  >  http://support.apple.com/kb/HT1808

  • To limit the access of PM data based on the Company Code, Plant & Location

    Hi Experts,
             I have a requirement . Customer wants to Restrict the access of PM data for a user based on the company code,
    Plant & Location.
    Say user : XYZ
    Plant :1000
    CCODE:1000
    Location:0001
    So you can see data of only this Organisation structure .No other data will be visible to him.
    I know we can do it using authorisation object
    Can you Suggest me how can we do this.
    Regards,
    Amar

    Hi,
    You can achieve this by maitaing these values in user authrisations. If you want more info about the objects check SU22 t code under PM.
    For Plant              I_IWERK
    For Location       I_ILOA
    Regards,
    N.Nagaraju

  • Drop the files into different directories based on the filename

    Hi,
    I had a reqiuirement based on the file name, i should drop the files in to different directories.
    I can get the filename through variable substitution in receiver file communication channel, now i want to drop the file into different folders based on conditions.
    suppose, if the file name is DDDX234
    i should do substring of filename0+(4), if the value is L then i should drop in X directory
    suppose, if the file name is DDDY234
    i should do substring of filename0+(4), if the value is L then i should drop in Y directory.
    How can i drop the file into differnent directories based on filename.
    Thanks
    Srinivas

    Thanks Michal,
    I mapped the directory and filename to the target header in the mapping
    Filename --> UDF --> Header(target)
    and in the receiver channel checked the ASMA and given * in the filename and directory name.
    But in runtime iam getting the error as
    Attempt to process file failed with com.sap.aii.adapter.file.configuration.DynamicConfigurationException: The Adapter Message Property 'FileName' was configured as mandatory element, but there is no 'DynamicConfiguration' element in the XI Message header
    MY UDF is
    public String Directory(String a,Container container){
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key  = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
    DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "Directory");
    String FileName = conf.get(key);
    FileName = a;
    conf.put(key, FileName);
    %%%based on filename the directory should change
    String Directory = conf.get(key1);
    Directory = "/SAPInterface/XI/PPD/DHX/out";
    conf.put(key1, Directory);
    return "";
    Help me in correcting this error.
    Thanks
    Srinivas

  • Dynamically changing the functions in a menu based on the user (in SSHR)

    Dear All,
    I have a requirement to change the functions in a menu dynamically.
    For Ex: An employee is allowed to apply Advance only in the first one month of his/her joining. I created it as an EIT and attached the function, to the menu. Now, i want to remove it automatically from the menu if his/her term in the company crossed one month.
    Can any one tell me how to automatically disable it after one month.
    Thanks and Regards
    Raj
    Edited by: SuperStar_Krishna on Jul 5, 2010 12:22 AM

    The following code should do it. In this example, MyCellRenderer is the renderer class implementing TableCellRenderer, used for displaying combo box.
    TableCellRenderer renderer= new MyCellRenderer();
    (JComboBox)renderer.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e) {
            //Your event handling goes here
    });

  • Dynamically rename the root node of XML based on the child elements

    Hi Gurus,
    Is there any way to rename the root node of the resultant XML after a mapping based on the child elements.
    For ex:
    consider the following resultant XML after mapping
    <result>
    <element1> </element1>
    <result>
    if the element1 is <type> then the output should be
    <category>
    <type> </type>
    </category>
    elseif the element1 is <character> then the output should be
    <property>
    <character> </character>
    </property>
    Let me know how to do this, either in XSLT or in Graphical mapping.
    Thanks,
    Prabu

    Hi, Prabu:
    In this case, I am suggest you have Src and Tar Message.
    I am suggesting you create another type of message using key / value pair as I suggested, e.g. called Mid Message.
    My solution for you is to have two message mappings:
    1. Src -> Mid
    2. Mid -> Tar.
    In first mapping, you have no control of the structure, but you can map it to Mid structure:
    e.g.
      if Type node Exist, then map 'Type' to Key, as Key/Value can be creatd under a parent node with 0:1 Occurrence.
      saying item.
       in this case, a new item created.
    If you think of this way, any xml file can be represted in this way:
       <Employee>
          <Fname>David</Fname>
          <Lname>Miller</Lname>
       </Employee>  
       <Employee>
          <Fname>Steve</Fname>
          <Lname>Mai</Lname>
       </Employee>   
    Can be interpretd as this way:
       <Employee>
          <Element>
             <key>Fname</Key>
             <value>David</Value>
          </Element>
          <Element>
             <key>Lname</Key>
             <value>Miller</Value>
          </Element>
       </Employee>  
       <Employee>
          <Element>
             <key>Fname</Key>
             <value>Steve</Value>
          </Element>
          <Element>
             <key>Lname</Key>
             <value>Mai</Value>
          </Element>
       </Employee> 
    Now you should understand what I mean.
    In your case target structure have to desgined as following way:
    You need to put Category and Property together with their sub-structure in parallel, make occurence to 0:1
    In your second mapping, you can check the key value is "Type" or "Character", based on which one is true,
    you create corresponding structure: either Categary or Property.
    Regards
    Liang
    Edited by: Liang Ji on Oct 22, 2010 8:31 PM
    Edited by: Liang Ji on Oct 22, 2010 8:35 PM

  • Determining the presence of an object based on the presence of multiple other objects.

    I have a form in which there are many subforms that become visible or hidden based on check boxes. I also built a report within a subform that is populated based on whether or not certain boxes are checked. My problem is that when everything in the report is hidden I want a text box to become visible and I'm not sure how to go about that. Basically, if all of the boxes are checked I don't want just a blank report, I want it to say something like "NO DEFICIENCIES NOTED"
    Thanks in advance,
    Bryant Coon

    Not sure I follow ..can you post the form to [email protected] so I can see it? I am sure what you are trying to do can be done it is just a matter of getting the right context. Also include a description of how to reproduce the problem.

Maybe you are looking for

  • How do I transfer music from my iPod to my iMac which crashed and had to be reformatted

    how do I transfer music from my ipod touch to my imac which crashed and had to be reformatted

  • OS X mavericks Won't install on SSD Plextor M5S 256GB

    Hi, I bought a Plextor M5S 256GB  for my mid 2012 macbookpro 13", and impossible to use my SSD so far... First I tried to clone my HDD to the SSD with carbon copy cloner, it works only when my SSD is in an external usb box... slow. When I select it t

  • Logic 9 32 bit Server randomly doesn't Show GUI

    It was really hard to get a solution to this because 99 percent of the problems were annoyingly about Logic X even though it clearly states it only runs 64 bits. This issue just randomly started. None of my 32 bit plugins will show it's GUI. The 32 b

  • Problem with Locales....???

    Users of my application have there first locale set to en-gb. Thus dates within the application are displayed in the English format. (e.g. 14-Mar-2007) The exception is that when generating a report ( a report is basically a document created on the f

  • Setup Time Capsule or Mac first?

    I'm getting a new Mac and a new Time Capsule. I currently do not have a wireless network or computer. In which order do I want to setup each of these? I don't want to miss anything during the initial setup process of either.