View Single Post
Old Apr 7th, 2009, 11:48 PM   #2
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 720
Rep Power: 7 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
Re: confused about multiple classes help simple question.

Well it depends, you can do either way really.

If you have a class set up for your fraction code, you could get the input in the main function and then pass it into your fraction object when you create it.

Something like
public class myProg {
    public static void main (String[] args) {
        float a, b, c, d;
        a = console.nextInt();
        b = console.nextInt();
        c = console.nextInt();
        d = console.nextInt();
        
        Fraction frac = new Fraction(a,b,c,d);

     }
   }
And then in your class something like
public class Fraction{
    public Fraction(float a, float b, float c, float d){
        addFraction(a,b,c,d);
    }
}

Or you can put it write into the class. In the end you get the same result.

Last edited by thechristelegacy; Apr 7th, 2009 at 11:49 PM. Reason: Typo
thechristelegacy is offline   Reply With Quote