Many Classes Vs Many Methods in one class

Can any one tell me what are the advantages & disadvantages - and which is better?
Having many methods (say about 15) in One class - about 10 doing various actions and not interrelated at all.
Vs
spliting the methods to be in their own classes, and instantiating them only when needed? Say in this case there could be about 10 classes thus created .
Thanks
Aarvi

>
I have got a chance to rewrite the existing code that
has about 75 "unrelated" methods in one class. ( do
not throw me out of this community now).
When I said, these methods should be put in their own
class based on their own functionality and can be
loaded only when it is called for. The counter
argument from the tech arch (!!) here is - "Why not
have it in one class? It works now". The tech arch is
a cobal type developer.
Hate to repeat what was said above (given the source) but.....
an object is not merely a collection of methods,
So far you have referred only to the methods.
Are there any data members?
If no then all you have is a collection of methods. You can of course still break them up but doing so doesn't necessarily mean it will be better. But in terms of the "tech arch" the impact is minimal. That of course doesn't mean that testing isn't required.
On the other hand if there is data then breaking them up would be based on how the data is used by the methods. As for why you would do that, the reason for the "tech arch" would be because the reason for using an OO language is so that one can have objects. And that 'class' is not an object.

Similar Messages

  • Moving a method from one class to another issues

    Hi, im new. Let me explain what i am trying to achieve. I am basically trying to move a method from one class to another in order to refactor the code. However every time i do, the program stops working and i am struggling. I have literally tried 30 times these last two days. Can some one help please? If shown once i should be ok, i pick up quickly.
    Help would seriously be appreciated.
    Class trying to move from, given that this is an extraction:
    class GACanvas extends Panel implements ActionListener, Runnable {
    private WorldMenuItems speedMenuItems, designMenuItemsPlantGrowth, designMenuItemsPlantCount;
         private WorldMenuItems designMenuItemsPlantEaten, designMenuItemsApproximatePopulation;
         private WorldMenuItems designMenuItemsEatersBorn,designMenuItemsMutationProbability;
         private WorldMenuItems designMenuItemsCrossoverProbability;
    MenuBar getMenuBar() {
              menuBar = new MenuBar();
              addControlItemsToMenuBar();
              addSpeedItemsToMenuBar();
              addWorldDesignItemsToMenuBar();
              return menuBar;
    This is the method i am trying to move (below)
    public void itemsInsideWorldDesignMenu() {
              designMenuItemsPlantGrowth = new WorldMenuItems("Plants Grow",
                        new String[] { "In Rows", "In Clumps", "At Random",
                                  "Along the Bottom", "Along the Edges" }, 1);
              designMenuItemsPlantCount = new WorldMenuItems("Number Of Plants",
                        new String[] { "50", "100", "150", "250", "500" }, 3);
              designMenuItemsPlantEaten = new WorldMenuItems("When a Plant is Eaten",
                        new String[] { "It grows back somewhere",
                                  "It grows back nearby", "It's Gone" }, 0);
              designMenuItemsApproximatePopulation = new WorldMenuItems(
                        "Approximate Population", new String[] { "10", "20", "25",
                                  "30", "40", "50", "75", "100" }, 2);
              designMenuItemsEatersBorn = new WorldMenuItems("Eaters are Born",
                        new String[] { "At the Center", "In a Corner",
                                  "At Random Location", "At Parent's Location" }, 2);
              designMenuItemsMutationProbability = new WorldMenuItems(
                        "Mutation Probability", new String[] { "Zero", "0.25%", "0.5%",
                                  "1%", "2%", "3%", "5%", "10%" }, 3);
              designMenuItemsCrossoverProbability = new WorldMenuItems(
                        "Crossover Probability", new String[] { "Zero", "10%", "25%",
                                  "50%", "75%", "100%" }, 4);
    Class Trying to move to:
    class WorldMenuItems extends Menu implements ItemListener {
       private CheckboxMenuItem[] items;
       private int selectedIndex = -1;
       WorldMenuItems(String menuName, String[] itemNames) {
          this(menuName, itemNames, -1);
       WorldMenuItems(String menuName, String[] itemNames, int selected) {
          super(menuName);
          items = new CheckboxMenuItem[itemNames.length];
          for (int i = 0; i < itemNames.length; i++) {
             items[i] = new CheckboxMenuItem(itemNames);
    add(items[i]);
    items[i].addItemListener(this);
    selectedIndex = selected;
    if (selectedIndex < 0 || selectedIndex >= items.length)
    selectedIndex = 1;
    items[selectedIndex].setState(true);
         public int getSelectedIndex() {
              return selectedIndex;
    public void itemStateChanged(ItemEvent evt) {  // This works on other systems
    CheckboxMenuItem newSelection = (CheckboxMenuItem)evt.getSource();
    for (int i = 0; i < items.length; i++) {
    if (newSelection == items[i]) {
    items[selectedIndex].setState(false);
    selectedIndex = i;
    newSelection.setState(true);
    return;

    Ok i've done this. I am getting an error on the line specified. Can someone help me out and tell me what i need to do?
    GACanvas
    //IM GETTING AN ERROR ON THIS LINE UNDER NAME, SAYING IT IS NOT VISIBLE
    WorldMenuItems worldmenuitems = new WorldMenuItems(name, null);
    public MenuBar getMenuBar() {
              menuBar = new MenuBar();
              addControlItemsToMenuBar();
              addSpeedItemsToMenuBar();
              worldmenuitems.addWorldDesignItemsToMenuBar();
              return menuBar;
    class WorldMenuItems extends Menu implements ItemListener {
         private WorldMenuItems speedMenuItems, designMenuItemsPlantGrowth, designMenuItemsPlantCount;
         private WorldMenuItems designMenuItemsPlantEaten, designMenuItemsApproximatePopulation;
         private WorldMenuItems designMenuItemsEatersBorn,designMenuItemsMutationProbability;
         private WorldMenuItems designMenuItemsCrossoverProbability;
         GACanvas gacanvas = new GACanvas(null);
       private CheckboxMenuItem[] items;
       private int selectedIndex = -1;
       WorldMenuItems(String menuName, String[] itemNames) {
          this(menuName, itemNames, -1);
       WorldMenuItems(String menuName, String[] itemNames, int selected) {
          super(menuName);
          items = new CheckboxMenuItem[itemNames.length];
          for (int i = 0; i < itemNames.length; i++) {
             items[i] = new CheckboxMenuItem(itemNames);
    add(items[i]);
    items[i].addItemListener(this);
    selectedIndex = selected;
    if (selectedIndex < 0 || selectedIndex >= items.length)
    selectedIndex = 1;
    items[selectedIndex].setState(true);
         public int getSelectedIndex() {
              return selectedIndex;
    public void itemStateChanged(ItemEvent evt) {  // This works on other systems
    CheckboxMenuItem newSelection = (CheckboxMenuItem)evt.getSource();
    for (int i = 0; i < items.length; i++) {
    if (newSelection == items[i]) {
    items[selectedIndex].setState(false);
    selectedIndex = i;
    newSelection.setState(true);
    return;
    public void itemsInsideWorldDesignMenu() {
         designMenuItemsPlantGrowth = new WorldMenuItems("Plants Grow",
                   new String[] { "In Rows", "In Clumps", "At Random",
                             "Along the Bottom", "Along the Edges" }, 1);
         designMenuItemsPlantCount = new WorldMenuItems("Number Of Plants",
                   new String[] { "50", "100", "150", "250", "500" }, 3);
         designMenuItemsPlantEaten = new WorldMenuItems("When a Plant is Eaten",
                   new String[] { "It grows back somewhere",
                             "It grows back nearby", "It's Gone" }, 0);
         designMenuItemsApproximatePopulation = new WorldMenuItems(
                   "Approximate Population", new String[] { "10", "20", "25",
                             "30", "40", "50", "75", "100" }, 2);
         designMenuItemsEatersBorn = new WorldMenuItems("Eaters are Born",
                   new String[] { "At the Center", "In a Corner",
                             "At Random Location", "At Parent's Location" }, 2);
         designMenuItemsMutationProbability = new WorldMenuItems(
                   "Mutation Probability", new String[] { "Zero", "0.25%", "0.5%",
                             "1%", "2%", "3%", "5%", "10%" }, 3);
         designMenuItemsCrossoverProbability = new WorldMenuItems(
                   "Crossover Probability", new String[] { "Zero", "10%", "25%",
                             "50%", "75%", "100%" }, 4);
    public void addWorldDesignItemsToMenuBar() {
         gacanvas = new GACanvas(null);
         itemsInsideWorldDesignMenu();
         Menu designMenuItems = new Menu("WorldDesign");
         designMenuItems.add(designMenuItemsPlantGrowth);
         designMenuItems.add(designMenuItemsPlantCount);
         designMenuItems.add(designMenuItemsPlantEaten);
         designMenuItems.add(designMenuItemsApproximatePopulation);
         designMenuItems.add(designMenuItemsEatersBorn);
         designMenuItems.add(designMenuItemsMutationProbability);
         designMenuItems.add(designMenuItemsCrossoverProbability);
         gacanvas.menuBar.add(designMenuItems);

  • Calling a method of one class from another withing the same package

    hi,
    i've some problem in calling a method of one class from another class within the same package.
    for eg. if in Package mypack. i'm having 2 files, f1 and f2. i would like to call a method of f2 from f1(f1 is a servlet) . i donno exactly how to instantiate the object for f2. can anybody please help me in this regard.
    Thank u in advance.
    Regards,
    Fazli

    This is what my exact problem.
    i've created a bean (DataBean) to access the database. i'm having a servlet program (ShopBook). now to check some details over there in the database from the servlet i'm in need to use a method in the DataBean.
    both ShopBook.java and DataBean.java lies in the package shoppack.
    in ShopBook i tried to instantiate the object to DataBean as
    DataBean db = new DataBean();
    it shows the compiler error, unable to resolve symbol DataBean.
    note:
    first i compiled DataBean.java, it got compiled perfectly and the class file resides inside the shoppack.
    when i'm trying to compile the ShopBook its telling this error.
    hope i'm clear in explaining my problem. can u please help me?
    thank u in advance.
    regards,
    Fazli

  • Methods of One Class In Another

    Can I make the methods of one class work in another?

    Thank you to all who responded so quickly. I want to be able to get information from my JTextFields in one class and put it into the Film class parameters of the class below. The film class is a JavaBean.
        import java.io.*;
    class SerializeFilm {
      public static void main(String args[]) {
        String [] actors = { "Harrison Ford", "Jean Connery" };
        String name= "Indiana Jones";
        Film film = new Film("Indiana Jones", "Aventure", 1989, actors, 2.0, 90);
        try {
          FileOutputStream file = new FileOutputStream(name + ".ser");
          ObjectOutputStream output = new ObjectOutputStream(file);
          output.writeObject(film);
          output.flush();
          output.close();
          } catch (IOException ex) {
             ex.printStackTrace();
    }

  • If there are two synchronized methods in one class.

    If there are two synchronized methods in one class then what will be the beheviour of the threads accessing the methods.

    Synchronization is on objects, not methods or classes. A thread, entering a synchronized method, synchronizes on the object on which that method is called. Another thread, attempting to synchronize on that object, will be made to wait until the first thread releases it.

  • Referencing a method in one class from a constructor in another?

    Hi,
    I'm not sure whether this is a simple question or not, but instead of rewriting the method in another class, is there a way that I can reference that method, eg:
    public int getTitleCode() {
            return titleCode;  }within the constructor of another class. I don't want to use inheritance with this because it would change all my existing contructors.
    Any ideas how to do this, or is it just simpler to add the method to both classes?
    Many thanks!

    Hi,
    I'm trying to use a method, defined in Class A, within one of the constructors in Class B. Class B object represents a copy of the output of Class A, with the addition of a few extra methods.
    Therefore to represent the details correctly in the saved text file for class B, I need to call a method from class A to save the text file for class B correctly.
    Class B saves a file with a reference number unique to that class, plus a reference number that is also saved in the text file for class A.
    I can achieve the correct result for the above by having the same method in both classes, but I just wondered whether instead of this I could in fact call the method from class A in the constructor for class B. With the following code,
        referenceNumber = refNum;
            titleReferenceNumber = titleRefNum;
            titleRefNum = titles.getTitleCode();
        }I just get a 'nullpointerexception' when I try to run this in the main class.
    Any help or advice appreciated!

  • How to call main method in one class from another class

    Suppose i have a code like this
    class Demo
    public static void main(String args[])
    System.out.println("We are in First class");
    class Demo1
    public static void main(String args[])
    System.out.println("We are in second class");
    In the above program how to call main method in demo calss from Demo1 class......???????

    No, i dont know how to call other than main methods from other classes
    And one more doubt i have i.e. Like in C can we see the execution of the program like how the code is being compiled step by step and how the value of the variable changes from step to step like(Add Watch).........

  • Invoke a method in one class from a different class

    I am working on a much larger project, but to keep this simple, I wrote out a little test that would convey the over all theory of the program.
    What I am doing is starting out with a 2 JFrames and a Class. When the program is launched, the first JFrame opens. In this JFrame is a label and a button. When the button is clicked, the second JFrame opens. This JFrame has a textField and a button. The user puts the text in the textField and presses the button. When the button is pushed, I want the text that was just put in the textField, to be displayed in the first JFrame's label. I am trying to invoke a method in the first JFrame from the second, but nothing happens. I have also tried making the Class extend from JFrame1 and invoke it from there, but no luck. So, how do I invoke a method in a class from a different class?
    JFrame1 (I omitted the layout part. I made this in Netbeans so its pretty long)
    public class NewJFrame1 extends javax.swing.JFrame {
         private NewClass1 nC = new NewClass1();
         /** Creates new form NewJFrame1 */
         public NewJFrame1() {
              initComponents();
              jLabel1.setText("Chuck");
         public void setLabels()
              jLabel1.setText(nC.getName());
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                                  
         NewJFrame2 j2 = new NewJFrame2();
         j2.setVisible(true);The class
    public class NewClass1 {
         public static String name;
         public NewClass1()
         public NewClass1(String n)
              name = n;
         public String getName()
              return name;
         public void setName(String n)
              name = n;
    }The second jFrame
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                                  
         NewClass1 nC = new NewClass1();
         NewJFrame1 nF = new NewJFrame1();     
         nC.setName(jTextField1.getText());
         nF.setLabels();
         System.out.println(nC.getName());At this point I am begging for help. I have been trying for days to figure this out, and I just feel like I am not getting anywhere.
    Thanks

    So, how do I invoke a method in a class from a different class?Demo:
    public class Main {
        public static void main(String [] args) {
         Test1 t1 = new Test1();
         Test2 t2 = new Test2();
         int i = t1.method1();
         String s = t2.method2(i);
         System.out.println(s);
    class Test1 {
        public int method1() {
         return 10;
    class Test2 {
        public String method2(int i) {
         if (i == 10)
             return "ten";
         else
             return "nothing";
    }Output is "ten".
    Edited by: newark on May 28, 2008 10:55 AM

  • Calling Parameterized Method from one class to another class

    Hi, below is my sample code
    test.java
    public class test
         int op1[][]=new int[][]{{1,2},{2,3},{4,5}};
         int row=0;
        public void  test() {
              int op2[][]=new int[][]{{2,3},{4,5},{6,7}};
                             row=1010;
              getRow(row);
        int[][] getList()
             return op1;
       public  int getRow(int klm)
             System.out.println("Row Value in GetRow Method  is:     "+row);
             return klm;
    test_2.java
    package aa;
    public class test_2
    int a;
         test t11=new test();
         int abc[][] = t11.getList();
         int rowCount=t11.getRow(a);
         public void test_2()
              System.out.println("Row Value is:     "+rowCount);
              System.out.println("Value in abc[1][1] is:     "+abc[0][1]);
    main_class.java
    package aa;
    public class main_class {
         public static void main(String args[])
              test ab=new test();
              ab.test();
              test_2 ba=new test_2();
              ba.test_2();
        public main_class() {
    }now that my question is,for 'rowCount' in class test_2.java i need to get the value of 'row'(which is 1010)from class test.java. How could that be done?
    Any reply is highly appreciable.
    Thanks in advance

    netbeans2eclipse wrote:
    hmm, i did chaged the test object in main method to same as the test object that i used in test_2 (ie; i changed test ab=new test() in main_class.java to test t1=new test()).What? How does this help?
    Again, simplify the problem
    For instance, say you have a class, Fubar1, like so:
    class Fubar1
      int value = 0;
      public void setValue(int v)
        value = v;
      public int getValue()
        return value;
    }and two different Fubar2 classes, both which try to get the value from Fubar1, one doing it badly:
    class Fubar2Bad
      Fubar1 f1 = new Fubar1(); // totally internal Fubar1 object
      public int getFubar1Value()
        return f1.getValue();
    }and one that does it well, that holds a reference to whatever Fubar1 object is passed to it:
    class Fubar2Good
      Fubar1 f1;
      public Fubar2Good(Fubar1 f1)
        this.f1 = f1;
      public int getFubar1Value()
        return f1.getValue();
    }Then if you test these:
    public class TestFubars
      public static void main(String[] args)
        Fubar1 f1 = new Fubar1();
        f1.setValue(35);
        Fubar2Bad f2Bad = new Fubar2Bad();
        Fubar2Good f2Good = new Fubar2Good(f1); // here we pass a reference to the main's Fubar1 object into the Fubar2Good object.
        System.out.println("Bad: " + f2Bad.getFubar1Value());
        System.out.println("Good: " + f2Good.getFubar1Value());
    }

  • How to use method of one class in other class.

    Hi.I am new to object orient approach .I am developing a project which has a class as application .My class has it state control as another class which is notification class.I want to use my notification class method (init)in my application class method .i have also used read and write accessors vis.But i have broken lines in my code.Please help me correct it. and print screen is attached below.
    Attachments:
    Application.docx ‏143 KB

    On the left, you have wired 2 sources on the same tunnel/wire, so that's 1 broken wire.
    In the For loop, you are trying to wire a "Red" object from the first subVI to the input of the "Green" subVI, so a "Green" object. If Red is not a descendant class of Green (or share a common ancestor), it is not permitted.
    FInally, the output of the For loop, is a 1D array of "Green" objects, which is probably not the same data type as the input of the last subVI on the right (it's probably a "Green" object scalar).
    Overall, you can use the "List Errors" dialog box (Ctrl+L) to debug your code, and make exhaustive use of the contextual help (Ctrl+H) to see what is going on when focusing a broken wire.
    Regards
    Eric M. - Application Engineering Specialist
    Certified LabVIEW Architect
    Certified LabWindows™/CVI Developer

  • Access instance method of a class inside instance method of another class

    Hi Friends
    I have to use one c1->m1.
    c1 is a public instantiation and m1 is a public Instance Method.
    I called this m1 method by creating c1 object for class c1.
    But problem is inise M1 method,i have a statement
    CALL METHOD mo_central_person->if_hrbas_pd_object~read_infty.
    here mo_central_person is of type some other class c2.
    As without creating the object,i didn't use the above interface method.
    Can please suggst me how to handle this.
    Regards,
    Sree

    class a definition.
      public section.
      methods : display,
                disp.
      data : a(10) type c value '10',
             b(5) type c value 'abc'.
    endclass.
    class a implementation.
      method display.
        write : a.
      endmethod.
      method disp.
        write : b.
      endmethod.
    endclass.
    class b definition inheriting from a.
      public section.
      methods : display1.
      data : c(7) type c value '7'.
    endclass.
    class b implementation.
      method display1.
       call method display( ).
        write c.
      endmethod.
    endclass.
    start-of-selection.
    data : o_obj type ref to b.
    create object o_obj.
    call method o_obj->display1.
    the method display is in class a.
    we can call this method in class b using the following statement.
    method display1.
       call method display( ).
        write c.
      endmethod.

  • ABAP Objects : calling one method from another class

    Hi,
    Can you please tell me how to call method from one class or interfce to another class.The scenario is
    I have one class CL_WORKFLOW_TASK, this class have interface IF_WORKFLOW_TASK & this interface have method IF_WORKFLOW_TASK~CLOSE. Now my requirement is ,
    There is another class CL_WORKFLOW_CHAIN ,this class have interface IF_WORKFLOW_CHAIN & this interface have method IF_WORKFLOW_CHAINCLOSE_ALL_PREDECESSORS. Now i have to write my code in this method but i have to use IF_WORKFLOW_TASKCLOSE method for closing the task.
    Can you please give me the code for the above .
    Please waiting for reply.

    Hi,
    You can use the concept of INHERITANCE  in this scenario.By using this concept, you can call all the public and protected  methods of class CL_WORKFLOW_TASK  in the required calss CL_WORKFLOW_CHAIN as per your requirement.
    Go through the  Introdctory(INHERITANCE) programming from this SAPHELP link.
    http://help.sap.com/saphelp_nw70/helpdata/en/1d/df5f57127111d3b9390000e8353423/content.htm
    I hope, it will help in you inresolving your problem.
    by
    Prasad GVK.

  • Calling a drawLine() from one class to another from an ActionEvent

    I have several JPanel objects called and placed on a JFrame. The JFrame has a RadioButton group with radio buttons. If I select a radio button and call a drawLine() method from a JPanel, I receive a "NullPointerException". Is it not possible to call this graphic method from one class to another?
    Thanks for any input you can provide.
    John

    Remember that each panel draws it's own current state. So you need the ActionPerformed to change the state in your target panel.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class PanelComm extends JPanel {
      private SubPanelOne subPanelOne = new SubPanelOne();
      private SubPanelTwo subPanelTwo = new SubPanelTwo();
      public class SubPanelOne extends JPanel {
        public SubPanelOne () {
          setLayout ( new BorderLayout() );
          setBorder ( BorderFactory.createTitledBorder ( "SubPanel One" ) );
          Reactor     reactor    = new Reactor();
          ButtonGroup group      = new ButtonGroup();
          JPanel      radioPanel = new JPanel(new GridLayout(0, 1));
          JRadioButton buttonOne = new JRadioButton ( "One" );
          buttonOne.addActionListener ( reactor );
          group.add ( buttonOne );
          radioPanel.add ( buttonOne );
          JRadioButton buttonTwo = new JRadioButton ( "Two" );
          buttonTwo.addActionListener ( reactor );
          group.add ( buttonTwo );
          radioPanel.add ( buttonTwo );
          JRadioButton buttonThree = new JRadioButton ( "Three" );
          buttonThree.addActionListener ( reactor );
          group.add ( buttonThree );
          radioPanel.add ( buttonThree );
          add ( radioPanel ,BorderLayout.LINE_START );
        protected void paintComponent ( Graphics _g ) {
          super.paintComponent ( _g );
          Graphics2D g = (Graphics2D)_g;
          g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
      public class SubPanelTwo extends JPanel {
        private JLabel text = new JLabel();
        public SubPanelTwo () {
          setLayout ( new BorderLayout() );
          setBorder ( BorderFactory.createTitledBorder ( "SubPanel Two" ) );
          text.setFont ( new Font ( "Verdana" ,Font.PLAIN ,30 ) );
          text.setHorizontalAlignment ( JLabel.CENTER );
          add ( text ,BorderLayout.CENTER );
        protected void paintComponent ( Graphics _g ) {
          super.paintComponent ( _g );
          Graphics2D g = (Graphics2D)_g;
          g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
        public void setChoice ( String cmd ) {
          text.setText ( cmd );
      public class Reactor implements ActionListener {
        public void actionPerformed ( ActionEvent e ) {
          subPanelTwo.setChoice ( e.getActionCommand() );
      public PanelComm () {
        setLayout ( new GridLayout ( 1 ,2 ) );
        add ( subPanelOne );
        add ( subPanelTwo );
      //  main
      public static void main ( String[] args ) {
        JFrame f = new JFrame ( "Panel Communication" );
        f.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
        f.getContentPane().add ( new PanelComm() ,BorderLayout.CENTER );
        f.setSize ( 320 ,120 );
        f.setVisible ( true );
      }  // main
    }

  • Calling results of a method from another class

    Very very new to Java, so apologies for the lack of basic knowledge. I am making a programme with 3 classes. One class gathers details about a module. Another about the results of this module (which requires some of the information inputted for the first class). For some reason I cannot find how to use results created in the first class in this second class. How do you call the results of a method from one class in another class?
    Thanks.

    Thank you.
    I am given the following information:
    '_ModuleRecord_
    This class is used to record information about a module taken by a single student. It has a constructor that takes three parameters:
    a Module,
    an int representing the examination mark achieved by a student, and
    an int representing the coursework mark achieved by a student.
    The class has another constructor that takes a single Module parameter.'
    and the code looks like this:
    public class ModuleRecord
      public ModuleRecord(Module m, int eMark, int cMark)
      public ModuleRecord(Module m)
      } I am a bit confused by the whole thing to be honest. I assume that the Module is referring to the other class, but how do I forge the link between them here?

  • Can I use object methods in a class

    I have a class ball and I am in the process of creating it's move method. I want this method to make the ball move depending on certain factors.
    One of these factors being where a bar has been stopped. I have a bar class which extends JProgressBar and when stopped, produces a number. I want this number to be available to my ball class in some way so it can use it to determine how far the ball has to move. The number can be output using its method getValue() but I am unsure how this can be used by another class.
    I doubt this is possible, but I am sure there are ways to achieve what I want. Any help on this subject would be great.

    Methods in one class can call methods defined in another class, subject to access restrictions (public, protected, package-private). This is pretty basic, so you should be able to get the meat of it from your text or tutorial. Look there, or in the following for explanations and examples, and post again if you can't get your code to work.
    http://java.sun.com/docs/books/tutorial/
    http://java.sun.com/learning/new2java/index.html
    http://javaalmanac.com
    http://www.jguru.com
    http://www.javaranch.com
    Bruce Eckel's Thinking in Java
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java

Maybe you are looking for

  • Huge size of ARTMAS IDOC

    Hello gurus, We are facing an issue in trasmiting generic articles(MARA-ATTYP = 01) along with all its variants via outbound ARTMAS IDOC(Transaction BD10). Some of the articles have around 40-50 variants. When such generic articles are transmitted vi

  • How to send byte array of image with 300dpi.

    Hello fiends                    i am making an application in which i have to send the byte array of an image with 300dpi. so i am using image snapshot class for that and use that code.                     var snapshot:ImageSnapshot = ImageSnapshot.c

  • How old is this Mac?

    Is there a way to tell how old this Mac is somewhere in the OS? I want to justify purchasing new ones. Below information is from the system profiler Model Name: Power Mac G5 Quad Model Identifier: PowerMac11,2 Processor Name: PowerPC G5 (1.1) Process

  • Video Length / media duration property

    Hi, Which managed / crawled property is used for media duration (video length)? i see there is one managed property named media duration that is mapped to the crawled property ows_MediaDuration - does it means that it'll work only on videos from Shar

  • Why do i get a resend pop up every time i refresh my yahoo email

    Recently i started to get a resend pop up every time i refresh my yahoo email. It's annoying as hell.