# OOP is freakin hars..

Page 1 of 1

## 2 Replies - 127 Views - Last Post: 07 August 2012 - 01:53 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=288123&amp;s=f3c34cde54154a6ee4f4562436e31c12&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Miikalsen

Reputation: 2
• Posts: 82
• Joined: 29-December 11

# OOP is freakin hars..

Posted 06 August 2012 - 02:13 PM

Okay, so I'm working on a Calculator using more OOP than my last Calculator.

This is what i got so far:

Main.java
```ackage rpg;

public class Main {
public static void main(String args[]){

Operators choice;
choice = new Operators();

Welcome choice2;
choice2 = new Welcome();

choice2.intro();

}
}

```

I'll not try to program in here, only to include other classes and methods.

Operators.java

```package rpg;

public class Operators {

}
void substraction(){

}
void divide(){

}
void multiply(){

}
}

```

Here will all of the operators be stored.

Welcome.Java
```package rpg;
import java.util.Scanner;

public class Welcome {

void intro(){
Scanner input = new Scanner (System.in);
System.out.print("Welcome to Calc 2.0");
System.out.println("2. Substraction");
System.out.println("3. Divide");
System.out.println("4. Multiply");
int input2 = input.nextInt();

}

}

```

Here you'll get question about how you want to do your math.

I'm still looking for a solution on what i should do now with the input and variables that stores the user input. Anyone got some idea?

Is This A Good Question/Topic? 0

## Replies To: OOP is freakin hars..

### #2 Ryano121

• D.I.C Lover

Reputation: 1055
• Posts: 2,234
• Joined: 30-January 11

## Re: OOP is freakin hars..

Posted 06 August 2012 - 02:18 PM

Glad to see you are trying some more OOP than last time

What you really need to do is start returning values from your methods (instead of void all over the place).

For example at the moment you intro method should return the integer choice which would then be passed into another method that decides what method in the Operators class to call.

Again you need to return values in the Operators class, not just void. You also should pass in the parameters to the operation to the method from the user input - e.g

```int add(int a, int B)/> {
return a + b;
}
```

Hopefully that gives you a few pointers.

### #3 Miikalsen

Reputation: 2
• Posts: 82
• Joined: 29-December 11

## Re: OOP is freakin hars..

Posted 07 August 2012 - 01:53 AM

Ryano121, on 06 August 2012 - 02:18 PM, said:

Glad to see you are trying some more OOP than last time

What you really need to do is start returning values from your methods (instead of void all over the place).

For example at the moment you intro method should return the integer choice which would then be passed into another method that decides what method in the Operators class to call.

Again you need to return values in the Operators class, not just void. You also should pass in the parameters to the operation to the method from the user input - e.g

```int add(int a, int B)/> {
return a + b;
}
```

Hopefully that gives you a few pointers.

Yeah I know that i should use something like that. Only thing is that i have not learned that by far as good with other things. But It's coming !