Re: Passing a Variable Between 2 Classes (school project)

return job.customerCode(custCd);There is no customerCode() method, there is also no custCd variable.

public double getApplicableDiscount()
    return applicableDiscount;
}There is no applicableDiscount variable.

Similar Messages

  • How to pass a variable from one class to another class?

    Hi,
    Is it possible to pass a variable from one class to another? For e.g., I need the value of int a for calculation purpose in method doB() but I get an error <identifier> expected. What does the error mean? I know, it's a very, very simple question but once I learn this, I promise to remember it forever. Thank you.
    class A {
      int a;
      int doA() {
          a = a + 1;
          return a;
    class B {
      int b;
      A r = new A();
      r.a;  // error: <identifier> expected. What does that mean ?
      int doB() {
         int c = b/a;  // error: operator / cannot be applied to a
    }Thank you!

    elaine_g wrote:
    I am wondering why does (r.a) give an error outside the method? What's the reason it only works when used inside the (b/r.a) maths function? This is illegal syntax:
    class B {
      int b;
      A r = new A();
      r.a;  //syntax error
    }Why? Class definition restricts what you can define within a class to a few things:
    class X {
        Y y = new Y(); //defining a field -- okay
        public X() { //defining a constructor -- okay
        void f() { //defining a method -- okay
    }... and a few other things, but you can't just write "r.a" there. It also makes no sense -- that expression by itself just accesses a field and does nothing with it -- why bother?
    This is also illegal syntax:
    int doB() {
          A r = new A();
          r.a;  // error: not a statement
    }Again, all "r.a" does on its own is access a field and do nothing with it -- a "noop". Since it has no effect, writing this indicates confusion on the part of the coder, so it classified as a syntax error. There is no reason to write that.

  • Help: I am trying to pass a variable between classes

    I am trying to pass data in a variable inbetween two classes is there any suggestions as to how to do this? Here is a example of the code I am trying to pass MqMessage to the class MqLog.
    if(MqMessage.equals("END"))               
                                       finalize();
                                       System.exit( 0 );
                             else //else build flat file and launch docusolve
                                       MqLog tempMqLog = new MqLog();
                                       tempMqLog.levelThreeDiagnostic();
                                       aRuntime = null;
                                       aProcess = null;                                   
                                  }

    I don't really undestand what you are asking specifically. If you only want to transfer a value from one Object to another Object, then you should just use a set method:
    if (objectOne.getValue().equals("END"))
    end();
    else
    objectTwo.setValue(objectOne.getValue())

  • Please help!! Can I pass a variable between 2 swf's that are on different html pages?

    Hey,
    Does anyone know how to pass a variable (string) from one swf
    to another if there in separate html pages?
    I assume I’d have to send the variable from the first
    page and load it into the second but I don’t know what
    functions or code I should be using. Any suggestions would be a
    HUGE help.
    Thanks
    If it helps: I’m creating a log in and sign up sheet
    that can be accessed from several sites. I’d like to record
    which site the user has come from when they signup.
    Thanks

    if they are open at the same time (for the same user), you
    can use the localconnection class to communicate between the
    two.

  • Passing a variable between functions [Silly Question]

    Hey, I am trying to write a program (who wouldve guessed) and I have the following problem. I set a variable in one function, but when I access it from another one, it is "undefined". How can I pass the variable, so both the functions see it? I thought the "public" class when defining a function should take care of that, but I was obviously wrong. Please help? (Code following...)
    public function dalsi_slovicko():void {
                   var pocet_slovicek = slovnikXML.slovicka.elements("*").length();
                   var cislo_slovicka = randomNumber(0, pocet_slovicek);
                   var slovicko_1 = ask(cislo_slovicka, "en");
                   var slovicko_2 = ask(cislo_slovicka, "cs");
                   slovicko1.text = slovicko_1;
    private function kontrola() : void {
              if (nazor.text == slovicko_2) {
                    dalsi_slovicko()
              else {
                   Alert.show("Špatně!! \n Slovicko_2 bylo:" + slovicko_2);
    Thanks...

    create the variable outside the functions so it is accessible for all the functions.
    private var slovicko_2;
    public function dalsi_slovicko():void {
                var pocet_slovicek = slovnikXML.slovicka.elements("*").length();
                 var cislo_slovicka = randomNumber(0, pocet_slovicek);
                 var slovicko_1 = ask(cislo_slovicka, "en");
                 slovicko_2 = ask(cislo_slovicka, "cs");
                 slovicko1.text = slovicko_1;
    private function kontrola() : void {
              if (nazor.text == slovicko_2) {
                   dalsi_slovicko()
              else {
                  Alert.show("Špatně!! \n Slovicko_2 bylo:" + slovicko_2);
    Also when you declare variables, set  appropriate datatypes

  • How can I pass a variable between JSP and Role Form

    I need to pass a variable from (a copy of) applicationmodify.jsp to the IDM Role Form so that the variable is available within the Role Form at display. We've tried getAttribute and setAttribute modifying both the Role Form and the applicationmodify JSP and can get the form to the role form but not accessible but have had no other success. Has anyone had any success in doing this? Any suggestions would be appreciated.

    if by _root level you mean you're loading something into
    _level0 you can't won't be able to use the localconnection. the
    sharedobject is your only option.

  • Passing a variable between applications

    Hi,
    I would like to pass a variable from a jsp page in a portal application into KM repository filter with user session context. For example, I will set { var1="sample data" } in the portal application and read it in the repository filter. Actually I am looking for a model like import/export statement in ABAP.
    Thank you,
    Orkun

    Hi Orkun
    Considering you aren't trying to send the variable in your url, you must concatenate your variable inside your well formed url and it must be considered during the iView configuration in your portal.
    KM is able to get all posts from the client once you have informed first the name of variable that  you are posting in your form.
    There's no need to use session context at this point, we must consider session contexts when talking about statefull session beans.

  • Instead of using session How to pass the variable from action class to JSP

    Im using Struts1.2 version.Created the Sample application to get the username.Upto action class im getting the username then i have to display the username in the JSP.Is there any options rather than using session variable to display the username.

    did you check the answer in your previous thread
    Passing Variable from Javascript to Controller

  • Passing Array variables between objects

    While troubleshooting a Flash app, it took me hours to figure
    out that you need to make a duplicate of an Array variable if you
    are passing it between objects. Otherwise, any alterations that you
    make to the array will result in the original array being altered
    as well as the "new" array.
    I'm no developer, can someone please explain why you have to
    do this? Or, give me an instance when you wouldn't want to make a
    duplicate? Just trying to understand.
    Thanks.

    it is because if you do something like this
    a=[1,2,3]
    b=a
    all you are doing is storing a reference to a in a variable
    b.Instead, either copy oput the array again or use one of the array
    methods which return an array eg
    b=a.slice()
    b=a.concat()

  • Pass table rowtype between java class and PL/SQL package

    I am a complete newbie when it comes to java itself but I've been asked to investigate the possibility of passing a rowtype datatype from a PL/SQL package to a java class and vice versa.
    I have heard of oracle.sql.ArrayDescriptor as an option but this appears to address only SQL types that are defined outside of a package.
    I'm talking about using, say, SCOTT.EMP%rowtype instead of a user-defined type. I'm thinking that a java array could be defined from the definition of a table in the database but I don't know what class would be appropriate.
    Could someone provide a simple proof-of-concept example that shows how you could use a java array to pass data to a package that is expecting a table rowtype variable and conversely a java class that reads the rowtype returned into a java array?
    Would oracle.jdbc.driver.OracleDatabaseMetaData be a way of doing this?
    Thanks!

    Kuassi:
    <br><br>
    Not at all. I didn't feel like you misled me at all. I'm grateful for your help. I think that maybe I failed to describe my problem adequately in the first place.
    <br><br>
    Perhaps I've also gotten stuck on the term <i>ref cursor</i>.
    <br><br> At any rate, the people I'm gathering information for have further refined their requirement. We want to take a collection of data and send it to a procedure. It doesn't have to be a "ref cursor" or "%rowtype" per se, but something that is maintainable and workable from both ends.
    <br><br>
    For example, to use the old SCOTT/TIGER paradigm, let's suppose we have a website where you can indicate which employees work for a given department. The website allows us to fill in information for multiple employees at once. We want to use a servlet that gathers all the employees data and sends it on through to a PL/SQL package so that the data is validated and committed in the database.<br><br>
    Perhaps the java servlet should handle the multiple employee records as an array? If so, how can a PL/SQL procedure be made to recognize that construct?<br><br>
    I can accept that java cannot create a "ref cursor" type to send information to a package, but might this be possible via some other implementation?
    <br><br>
    Hopefully this is a little more clear. If not, please let me know and I'll try to inject more details as to what we are trying to accomplish.
    <br><br>
    Once again, thanks for your persistent replies and help.
    <br>

  • Passing a variable from one class to another

    Hello:
    I am new to java programming. I am developing an application in Java
    At a particular JTextField call it jtf3, I am invoking Calendar application by clikcing a jbutton.
    I would like to set text in jtf by obtaining the date clicked by the user. I am storing complete date string in the Calendar application during ActionPerformed event at Calendar Application level.
    I do not know how to pass this string to calling frame as it does not listen to the button event happening at the Calendar Application.
    Much appreciated
    Thanks a lot for your time
    regards

    This is the application from which the I am calling the calendar application.
    The method setDate set the date obtained from calendar class during actionperformed event.
    The actionperfomed event from CalendarClass is pasted below as well.
    Much appreciated
    import javax.swing.JFrame;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;
    import java.awt.*;
    public class TestDrive
    public static void main(String[] args) {
    DatePanelFrame dpf = new DatePanelFrame();
    dpf.addWindowListener(new WindowAdapter( ) {
    public void windowClosing(WindowEvent we) { System.exit(0); }
    dpf.pack();
    dpf.setVisible(true);
    class DatePanelFrame extends JFrame {
    JTextField djtf;
    String dateInput;
    public DatePanelFrame() {
    setTitle("Date Panel");
    setSize(100, 800);
    setLocation(300, 100);
    Container content = getContentPane();
    JPanel datePanel = new JPanel();
    JButton calButton = new JButton(".....");
    datePanel.add(calButton, BorderLayout.SOUTH);
    djtf = new JTextField(" ");
    datePanel.add(djtf, BorderLayout.NORTH);
    content.setLayout(new BorderLayout());
    content.add(datePanel, BorderLayout.CENTER);
    calButton.addActionListener(new ActionListener()
              public void actionPerformed(ActionEvent event)
    JFrame fr = new CalendarClass();
    fr.setSize(400, 400);
    fr.setLocation(600, 100);
    ObjCal oc = new ObjCal();
    fr.setVisible(true);
    public void setDate(String d)
    djtf.setText(d);
    repaint();
    System.out.println(djtf.getText());
    The ActionPerformed event from CalendarClass
    jbtArray.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent event)
    if (event.getActionCommand() != " ")
              daySelected = event.getActionCommand();
              yearSelected = jtfYear.getText();
              int intYearSelected = Integer.valueOf(yearSelected).intValue();
              monthSelected = jtfMonth.getText();
              intDaySelected = Integer.valueOf(daySelected).intValue();
              int intMonthSelected = getMonthNum(monthSelected);
              dateSelected = getDate(intYearSelected, intMonthSelected, intDaySelected);
              TestDrive td = new TestDrive();
              DatePanelFrame dpf = new DatePanelFrame();
              dpf.setDate(dateSelected);

  • How to pass a variable in current class for access in next class.

    Hi Everyone,
    I'm new in this iphone development.so please anyone help me .
    My question is How can we declare a variable for, select a row in current class which read as input string in next class Soap Message.
    Means in my 1st class i am getting web response in array as a name like john, now if i m clicking on john so its call another web service for john details.so how can i select ( john ) cell to call in next class Soap Message.
    Please anyone help me..
    Sorry for bad english.
    Regards:
    Maddy

    You need to ask in the iPhone Developer forums:
    http://devforums.apple.com

  • How to pass local variables between different sequence files?

    Actually i want to pass the data (local variable) from my process model file to a client file. The client file only has the callbacks and those callbacks require some parameters as input which is available in local variables of my process model sequence file. I do not want to use Station Globals.
    Please tell me any other way by which i can pass that data.

    Which Locals do you want from the model.  Every sequence has it's own Locals and there are a bunch of sequences in every process model.  Do you want the entry point's Locals?  A callback's Locals?  Just one of the sequence's Locals?  Some Models have way more entry points than others.  What if your sequence file is ran with a different entry point?
    One option is to create your own callback in the model and pass the data to it as parameters.  Then add that callback to your client sequence file and get it out of the parameters.
    If you simply want the entry point's locals and you are in your Main Sequence then you could use RunState.Caller.Locals.VariableName.  This assumes you will use the same entry point every time you run that sequence file.  Or assumes that every entry point you run has the same Local variable name.
    Maybe there is an API method that exposes what you are looking for.  What is your goal?
    Regards,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • Passing string variables between servlets

    Hello
    I need to pass an SQL string constructed in Java servlet A to Java servlet B where it can be executed.
    For example:
    In servlet A I have:
    String cmd = ("select x from y where z");
    cmd is then passed to the server as a hidden form field and read by servlet B as:
    if (paramName.equals("cmd")) {
    String cmd = paramValue;
    However, displaying cmd in servlet B shows only:
    "select"
    Is there a way around this at all? That is, other than converting all spaces to another character in servlet A and reinstating the spaces in serlvet B?
    Thanks
    Martin O'Shea.

    marti,
    you are posting the form aren't you... not getting it?
    I'm suspecting that it's a side-effect of URL rewriting.
    http://en.wikipedia.org/wiki/Rewrite_engine
    And of course a better approach is create user model in the session facade... and if you don't know what that means then forget it.
    keith.

  • Passing a variable between html and jsp

    Hello there,
    I'm writing a simple application to show the use of custom tags. I have an html page with a dropdown box. Based on the selection from the dropdown box what the jsp outputs will be different. Can anyone tell me how to use the variable from the html page in the jsp page? The code is as follows:
    manager.html <form method="post" action="manager.jsp">
              <body>
                   <form>
                        <select name="person">
                        <option value="pevans">PEVANS
                        <option value="mgleeson">MGLEESON
                        <option value="jmolony">JMOLONY
                        <option value="pmccarthy">PMCCARTHY
                        <option value="jwalsh">JWALSH
                        </select>
                        <input type="submit" value="Submit" />
                   </form>
              </body>
    </form>and manager.jsp
    <%@ taglib prefix="man" uri="/tags/weekdayTags"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <table border="1">
         <man:forEachLine manager="html selection" var="line">
              <tr>
                   <c:forTokens items="${line}" delims="," var="field">
                        <td><c:out value="${field}"/></td>
                   </c:forTokens>
              </tr>
         </man:forEachLine>
    </table>Thanks very much,
    Ger

    You need to use the response.getParameter("selectName") method which will return a String with the selected value.

Maybe you are looking for

  • Can i share an iPhoto library between 2 computers ???

    Can i share an iPhoto library between 2 computers, it I store my library on a AS drive connected to an AirPort Extrême Base Station ?

  • Create a free item PO

    Hi, Gurus, I try to create a Free Item PO in account assignment category P, so I put net price as 0 and I checked free box. But the system always ask me to check the GR based IV box, also Inv receipt box. However, once Inv receipt box is checked, the

  • Receiver mail adapter configuration for e-mail attachments

    Hi , I need to send two files from sender file adapter to receiver mail adapter as e mail attachment. I want same attachment name in email as on sender side on FTP location. This is by pass scenario no object created in ESR.Please suggest how to hand

  • Mail not saving changes in Mailbox Behaviors

    For one of my accounts since the upgrade to Mavericks when I enter the Mailbox Behaviors section, I found that Drafts, Junk and the one under Trash named Store Deleted messages on the server is checked. I uncheck them because I doon't want them check

  • Hi time shot problem

    Hi, I have a small problem. Time slot divisions. In my selection screen I have taken Date and time fields. If I entered one date (suppose 03/01/2006) and time slot as (12:04:56 to 05:08:34) . I need the output as: Date:03/01/2006 12:00:00-12:59:59 01