Mutator to compute set and return the value

Hi
I am having trouble working out how to do a mutator that does all three
compute a value set the value and then return it this is what i have so far
this example calculates and returns the value but does it set the value of totalSlices ???? this is the best option so far
public int totalSlices (){
int total = meatSlices + vegSlices;
return (int) total;
this one seems more likely to me but unsure is this a set method as well
public insert (int fiveC)
fiveCentCoin += fiveC;
returne fiveCentCoin;
this is the final example i have come up with but dont know if it sets the value as well
public int calculateCost () {
double cost;
if (age==0) {
age = 0.1;
if (neutered) {
cost = (100/age) + (stay * 3) + SHOTS + TAGS;
} else {
cost = (100/age) + (stay * 3) + SHOTS + TAGS + NEUTER;
return (int) Math.round (cost);
the problem i face i am not sure of how to combine a mutator calculation, set method and return it all in one i havnt done that before and cannot find an example
thanks

I think you're trying to take a hollistic approach to programming. That won't work.
You need to go back and get a good understanding of exactly what each element of Java does.
Sylvia.

Similar Messages

  • SUBMIT and return the value of that report into internal table

    Dear all,
    I have a requirement. I want to submit a report and return the value of that report into my internal table.
    How to do this.
    Pl. guide.

    Hi Vidhya,
    Below links from SAP help will resolve your issue.
    http://help.sap.com/saphelp_nw04/Helpdata/EN/fc/eb3bde358411d1829f0000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3bd1358411d1829f0000e829fbfe/content.htm
    Edited by: Harsh Bhalla on Jan 2, 2010 11:54 AM

  • How crm visit the external website and return the value to crm

    how crm visit the external website and return the value to crm?
    Awen

    Can you elaborate the question? I assume that you are looking for some sort of mechanism to validate a customer's web site?
    Regardless of the scenario, the way to validate or retrieve a value from an external web site is to write a plugin that executes a WebRequest to the external site and reads the response.

  • Linking two DCs using interface views and return the value

    Hi,
    I have two webdynpro DCs. DC1 & DC2, each contains one view.
    Point 1:  From the DC1-->DC1View1 ,when I click a button , It should call  DC2(This is happening).
    Point2: When the DC2 is executed it should return to DC1-->DC1View1, value from DC2 need to be passed to DC1 also.
    How to acheive  point2. How anyone help on this .
    Regards,
    Muhammed Nishad J.

    Hi,
    You would have created a inbound and outbound plug between DC1-->DC1View1 and DC2 ->View.
    Now you will have to create the same for DC2 ->View and DC1-->DC1View1
    1) create an inbound plug on DC1-->DC1View1 and outbound plug on DC2->view.
    2) Now create a link as you would have in the first case.
    3) create a parameter in DC2->view for outbound plug, and also the same in inbound plug of the DC1->view
    4) Now in the method that was created for the outbound(public void onPlug<name of plug> )pass the value into the parameter created
    5) in the inbound method(public void onPlug<name of inbound> get the value of the parameter in a variable.
    I hope this solves your problem.
    Thanks and Regards,
    Narayani

  • How to search two columns and return a value in the same row to a cell?

    Identification
    Diameter
    Soak
    3" Tank (inches/kft)
    AWG
    mils
    Code
    Strands
    Shield
    Conductor
    Insulation
    Semi-Con
    Days
    SD
    Injection
    Soak
    Total
    2
    175
    00
    7
    External
    0.288
    0.692
    0.752
    60
    0.4
    3.6
    20.0
    23.6
    2
    220
    00
    7
    External
    0.284
    0.764
    0.864
    75
    0.4
    3.6
    20.0
    23.6
    2
    260
    00
    7
    External
    0.284
    0.844
    0.944
    90
    0.4
    3.6
    21.8
    25.4
    2
    320
    00
    7
    External
    0.288
    0.964
    1.064
    110
    0.4
    3.6
    24.3
    27.0
    2
    345
    00
    7
    External
    0.288
    1.014
    1.114
    115
    0.4
    3.6
    25.6
    29.2
    Length
    3"
    4"
    AWG
    mils
    Soak
    SD
    Injection (3")
    Injection (4")
    650
    2
    320
    I want to input two values, AWG and mils and return the value in the Days column. 
    In the instance of what I am showing ....   AWG=2 AND mils=320 so Soak=110 ....
    I want to search the columns (AWG) AND (mils) to return a value in the column (Days) for that row into cell H10 (Soak)  ...
    So far I have toyed with LOOKUP, INDEX and MATCH ....

    SCW,
    I'm sure there is a clever way to cascade functions to avoid adding an auxiliary column in your practice table, but to me it wouldn't be worth the aggravation. I would add a column that concatenates Columns A & B, AWG & mils. This column can be anywhere and would be Hidden. Let's say your new column is Column N.
    In Column N, fill the body rows with:
    =A&"-"&B
    As good Numbers programming form would indicate, let's name the Practice Table Practices and only put the practices in that table. In another table where you do the lookup, let's call it Program, we will have the calculation/lookup.
    Based on your example, I'd guess that AWG may be in Column D and mils in Column E of your Program table, and the Soak lookup in Column F. If I'm wrong, adjust the column id.
    In Column F, write:
    =OFFSET(Practices::I$1,MATCH(D&"-"&E, Practices::N,0)−1, 0)
    The hyphen in the concatenated representation of the combination of AWG and mils is just tp make it more readable.
    As I'm sure you know, you could use other approaches, but since I had you put your aux column at the end of your Practices table, OFFSET with MATCH is a clean approach. INDEX could be used too.
    Here's an illustration:
    Regards,
    Jerry

  • Exchange Mail Store Lookup Reconciliation no longer returns the values

    Hi guys,
    I executed the schedule "Exchange Mail Store Lookup Reconciliation" and returned the value of mail store with sucess. Now I run again but not return the values. The values existed on the Lookup.ExchangeReconciliation.MailStore was cleaned.
    I need this values for provision a user to Exchange. Is it ok?
    Thanks

    I execute the task, is finished with success. But not bringer any values to Lookup.ExchangeReconciliation.MailStore
    [2012-01-11T11:08:39.250-02:00] [oim_server1] [NOTIFICATION] [] [OIMCP.MEXC] [tid: OIMQuartzScheduler_Worker-9] [userId: oiminternal] [ecid: 0000JJCoOzaE^MWFLzyGOA1F3OLz000002,0] [APP: oim#11.1.1.3.0] com.thortech.xl.schedule.tasks.tcExchangeMailStoreLookupReconTask : execute : Starting Exchange Mail Store Lookup Reconciliation Task
    [2012-01-11T11:08:39.255-02:00] [oim_server1] [NOTIFICATION] [] [OIMCP.MEXC] [tid: OIMQuartzScheduler_Worker-9] [userId: oiminternal] [ecid: 0000JJCoOzaE^MWFLzyGOA1F3OLz000002,0] [APP: oim#11.1.1.3.0] com.thortech.xl.schedule.tasks.tcExchangeMailStoreLookupReconTask : isReconStopped : Stopping Reconciliation.....................
    [2012-01-11T11:08:41.924-02:00] [oim_server1] [NOTIFICATION] [] [OIMCP.MEXC] [tid: OIMQuartzScheduler_Worker-9] [userId: oiminternal] [ecid: 0000JJCoOzaE^MWFLzyGOA1F3OLz000002,0] [APP: oim#11.1.1.3.0] com.thortech.xl.schedule.tasks.tcExchangeMailStoreLookupReconTask : execute : Exchange Mail Store Lookup Reconciliation Ends
    For provision a user to Exchange, I need select a "Mail Store" on the form. But if task "Exchange Mail Store Lookup Reconciliation" not bring the values to Lookup, I can not provision a user. I'm correct?
    Because when I try provision a user to Exchange, in the log, show me:
    [2012-01-11T11:05:00.508-02:00] [oim_server1] [ERROR] [] [OIMCP.MEXC] [tid: [ACTIVE].ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: xelsysadm] [ecid: bfccc7416174d6cc:6f5adea4:134ccd17bf0:-8000-000000000000025a,0] [APP: oim#11.1.1.3.0] com.thortech.xl.integration.Exchange.tcExchangeTasks : createMailboxForADUser : Insufficient data, may be all mandatory field are not present : :Index: 0, Size: 0
    [2012-01-11T11:05:00.509-02:00] [oim_server1] [ERROR] [] [OIMCP.MEXC] [tid: [ACTIVE].ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: xelsysadm] [ecid: bfccc7416174d6cc:6f5adea4:134ccd17bf0:-8000-000000000000025a,0] [APP: oim#11.1.1.3.0]
    Thanks a lot

  • I have now transfered my files of ripped CD's to my iTunes library three times. On each occassion, the conversion seems to occur fine, the files play, but when I close my computer and return the next day, iTunes says it cannot locate any of those files.

    I have now transfered my files of ripped CD's to my iTunes library three times Since upgrading to iTunes 11 and Windows 8. On each occassion, the conversion seems to occur fine, the files play, but when I close my computer and return the next day, iTunes says it cannot locate any of those files. Three times. Beginning to lose my temper. Advice? Suggestions? Could the fact that my original library is located on a network drive have anything to do with it? Thanks for your help, all.

    Repair security permissions
    Right-click on your main iTunes folder and click Properties, then go to the Security tab and click Advanced. If necessary grant your account and system full control to this folder, subfolders and files, then tick the option to replace permissions on child objects which will repair permissions throughout the library. This is the XP dialog but Windows 7/8 shouldn't be too different.
    Repeat for the media folder if it isn't a subfolder of the iTunes folder.
    tt2

  • Insert record and return the primary key

    Okay, I need to insert a record into a MSSQL database and return the primary key of that record. Im using the following code which is obviously wrong as I'm getting either 'NULL' or 'com.microsoft.jdbc.base.BaseResultSet@1d520c4' returned depending on the ways I've tried. The primary key is an int value called clientID which is incremented by one each time a new record is added.
    // set the prepared statement
                String sql="INSERT INTO Client(username, country, clientIP, browser, os) VALUES(?,?,?,?,?)";
                PreparedStatement pstmt = conn.prepareStatement(sql);
                pstmt.setString(1, inUserName);
                pstmt.setString(2, inCountry);
                pstmt.setString(3, inClientIP);
                pstmt.setString(4, inBrowser);
                pstmt.setString(5, inOS);
                // Insert the row
                pstmt.executeUpdate();
                Statement stmt = conn.createStatement();
                ResultSet rs = stmt.executeQuery("SELECT SCOPE_IDENTITY()");
                System.out.println("Result "+rs);The primary key value is needed so that it can be used as a foregin key in another table. Am I going about this the correct way? Any help, pointers or code fixing would be appreciated.....

    Yes. I tried this way but I only ever get the answer
    of 0 when i print our the result! Not really sure
    whats happening.That's because you don't print a ResultSet like that. In order to get the key out, you have to do this:
    int key = 0;
    while (rs.next())
        key = rs.getInt(1);What were you thinking with your code?
    You might want to do this in a transaction. If the INSERT fails, you'll want to roll back.
    The "select @@identity" is correct for M$ Access, SQL Server, and Sybase. I believe it's also correct for MySQL, but I'm not 100% certain of that.
    %

  • Need help parsing a long and passing the value.

    I'm doing Cattle Drve 4b on javaranch.com (http://www.javaranch.com/say.jsp) and I need a bit of help.
    I want to pass the reference of my num value to several small methods to work out the value printed. Here's the original code I did from 4a:
    public class Say{
    public static void main(String[]args){
    int num = Integer.parseInt(args[0]);  // parse argument from command line
    String array[] ={"Zero", "One", "Two", "Three", "four", "five", "six","seven","eight",
               "nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen",
               "seventeen","eighteen","nineteen","twenty","thirty","fourty","fifty",
               "sixty","seventy","eighty","ninety"};     //initialize the array
    //start check for value
    if(num<21)
    System.out.println("\n" + array[num]);
                                            //  \n is added before
    else if(num<30)                                   //  each result for a
    System.out.println("\n" + array[20]+ "-" + array[(num-20)]);     //  cleaner output
    else if(num<40)
    System.out.println("\n" + array[21]+ "-" + array[(num-30)]);
    else if(num<50)
    System.out.println("\n" + array[22]+ "-" + array[(num-40)]);
    else if(num<60)
    System.out.println("\n" + array[23]+ "-" + array[(num-50)]);
    else if(num<70)
    System.out.println("\n" + array[24]+ "-" + array[(num-60)]);
    else if(num<80)
    System.out.println("\n" + array[25]+ "-" + array[(num-70)]);
    else if(num<90)
    System.out.println("\n" + array[26]+ "-" + array[(num-80)]);
    else if(num<100)
    System.out.println("\n" + array[27]+ "-" + array[(num-90)]);
    //endFor 4b I need to be able to print out values in the billions, so I was going to create a few methods to keep it clean like so:
    public class billion (long (int num)
    { if( num<9 billion)
         num-= 8 billion
    System.out.print("eight billion ");
    else if(num<8 billion){
    num-= 7 billion
    System.out.print("seven billion ");
    ....etc
    return num;
    public class million...
    public class thousand...
    etc.And the current main section will be moved into a new "tens" class.
    I'm running into two problems though.
    1. How do you parse a long? I know integers are like so:
    int num = Integer.parseInt(args[0]); are longs the same?
    like:
    long num = Long.parseLong(args[0L])if not, how can I do it?
    2. how do I properly pass num to all the methods? I'm going to make num a public int and make the methods public because that seems simplest, but can I pass num to the method and then return the new value of num back to main?
    BTW, I'll be removing the carriage return from the beginning of the "tens" class when all is said and done so the results don't end up printing on multiple lines.
    Thanks in advance everyone.

    The L suffix is used to identify a Long literal.
    The index of the args[] array does not need to be specified as a Long.
    Solong num = Long.parseLong(args[0]);will suffice. You might want to put that in a try/catch block to catch the NumberFormatException that will be thrown if args[0] cannot be parsed to a long value.
    Various ways to update the value of num in the methods of the same class:
    Simplest of all: declare num as an instance variable. The methods simply access and assign its value.
    Other ways:
    -- pass num as a parameter to the method.
    -- return the value of num from the method (provided the method doesn't have to return any other value)
    -- Have a getNum() method return the value of num
    -- Have setNum() method to update the value of num
    db
    What's that line? public class billion (long (int num)edit Typos, typos...
    Also, the set/get approach with public access is the preferred method when used in the methods of another class.
    Don't forget that the other class has to know whose set/get methods to call.
    Message was edited by:
    Darryl.Burke

  • I am trying to build a basic TCL skeleton script that reads a remote SNMP OID and displays the value on the screen.

    I am trying to build a basic TCL skeleton script that reads a remote SNMP OID and displays the value on the screen.
    I don't want it to be an EEM Event, I just want to run it from the (tcl)# prompt.
    So I guess I'm asking if you can use cli_exec and other commands in the "namespace import ::cisco::eem::*" in a normal non-EEM script - can I do that?
    This is the error I get:
    OTN.159(tcl)#source flash:TCL_SNMP_Remote_Read.tcl
    invalid command name "::cisco::eem::event_register_none"             ^
    % Invalid input detected at '^' marker.
    What am I missing?
    =================  TCL_SNMP_Remote_Read.tcl  ==============================
    ::cisco::eem::event_register_none
    namespace import ::cisco::eem::*
    namespace import ::cisco::lib::*
    if [catch {cli_open} RESULT]
        { error $RESULT $errorInfo }
        else { array set cli1 $RESULT }
    if [catch {cli_exec $cli1(fd) "snmp get v2c 192.168.1.100 public timeout 1 oid 1.3.6.1.2.1.1.1.0" } RESULT]
           { error $RESULT $errorInfo  }
           else { set SnmpSysDesc $RESULT }
    if [catch {cli_close $cli1(fd) $cli1(tty_id)} RESULT] {
                error $RESULT $errorInfo
    puts $SnmpSysDesc
    =========================================================================
    In the sho-run config I have:
    event manager directory user policy "flash:/"
    event manager session cli username "cisco"
    Any help to get me started would be greatly appreciated!
    Tim

    If you don't want an EEM policy, then don't use any of the EEM constructs.  Instead, all you need is this:
    set output [exec "snmp get v2c 192.168.1.100 public timeout 1 oid 1.3.6.1.2.1.1.1.0"]puts $output

  • How do I click on a cell in a table control, and display the value in a string?

    What I would like to do is to click on a cell in a table control, and have the value of the cell be displayed in a string indicator. What ever cell I click on, I would like the value to be displayed in the indicator.
    Thank you!
    Solved!
    Go to Solution.

    ... or
    Event >>> ouse down for table.
    Use Coords" to feed invoke node "point To Row Column" and returned "Cell Postion" can be unbundled to produce the row and column tht can be used to index out the value.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to retrieve the procedure value and pass the value to a form field

    How to retrieve the procedure value and pass the value to a form field?

    Set property for the field and the value is the actual procedure/function.
    Cheers

  • BAPI OR RFC THAT RETURNS THE VALUE TABLE CONTENTS THAT IS SPECIFIED IN DOM

    HI ALL,
    i have requirement of BAPI  or RFC that returns the value table contants(text table) in CRM..
    for ex:
      if i  pass the dataelement or domain or checktable as input parameter,could i get the contents of its text table associated with it....
    please if there is way help me on this..
    thanks and regards,
      goutham,

    Check these FM
    RFC_READ_TABLE
    RFC_GET_TABLE_ENTRIES

  • HT1430 My beautiful teens tried to decode my iphone and got me up to 22,000 minutes to reset my old iphone that i know use as a pandora radio.  how can i reset the setting and bypass the disabled msg

    My beautiful teens tried to decode my iphone and got me up to 22,000 minutes to reset my old iphone that i now use as a  radio to listen to pandora music.  how can i reset the setting and bypass the disabled msg

    If you want to Restore iPhone Firmware. Open iTunes on computer. Connect iPhone to computer with USB Cable. Then hold both home and power buttons until iTunes recognizes iPhone in Recovery Mode. This usually takes about 20 seconds of holding both buttons. Then click Restore button of iTunes.

  • UDF for reading a particular line and storing the value in a variable

    Hi Experts,
    I am reading entire file content in single feild in source data type.I want to write a UDF to seach for a particular pattern(say :25: and store the value after it i.e  34535764778 detination for further use).
    EX: My  sample file and its  has feilds like
    point assured
    Thanks

    Hi since u are using a single field only then u dont need to use any advanced function
    Wel because if u see the formation of the queue u wil find the the whole data is under one context.. and there are not more context changes
    Convert the string to an array and progressively u can check for the four checks if the a<i>=:
    then a[i+]=2 then a[i]=5 and a[i+] =: and then substring the next 7-8 chrac.. hope u understand
    If this also doesnt work wel then u will have to use the Pattern class in Java
    By the way remember that the substring value cant be retained for the next instance of mapping
    Hope u have that in mind...
    Rgds
    Aditya

Maybe you are looking for