Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link

Yuhri Hirata

Greenhorn
+ Follow
since Jun 13, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Yuhri Hirata

It's possible I'm misunderstanding your problem. But. From what I vaguely gathered from your problem, this is what you need to do.

Your best bet is to pass in the object you want via a constructor or a secondary method, something contained in class B (for instance).

..and then in class A, call the setA method: B.setA(this);
21 years ago
I've tried dinking around with this class but I'm not really getting much success out of it.
Basically, I'm trying to format decimals to reflect pricing on a bank account system: #,##0.00 -- so how do I do this? It doesn't have to involve the DecimalFormat class; I simply mention that one since it's the only useful format system I can find.
Any suggestions?
21 years ago
I've been surfing the web and the odd reference book to see if I can find any mention of exception handling in class diagrams. I got one for CORBA exception mapping from a classmate; I found another that simply marked Exceptions as notes inside the diagram without any reference to the classes the exceptions belonged to.
Has anybody else come across alternative methods for mapping exceptions to UML?
By the code that you have written there, you would get an endless loop of 0. j and i would always be zero.
0+0 = 0, which will always be less than 20.
0 = 0+0, which is no increment.
Java is case-sensitive.
Therefore, (for instance), 'int max' is not the same as 'int MAX'. Along the same lines, method 'Amethod()' is not the same as 'amethod()'.
Check your APIs:
java.lang.System
static void gc()
Suggests to the JVM that it run the garbage collector. Note that it only 'suggests'! ...but in theory, it does give you a measure of control over its running.
Actually, according to my books, it turns out that postfix (++) and parentheses have the same precedence. FYI, you don't need the () around a i++, except for clarity purposes. () has precedence when it forces an arithmetic formula before another takes place on that group.
For instance: d = 3 + 2 * 5;
d = 13.
On the other hand: d = (3 + 2) * 5;
d = 25.
...which is sort of besides the point. The reason that the i++ doesn't increment despite the parentheses is that the purpose of the operator itself, ++, is to increment /after/ its use in the expression. Use of the parentheses won't negate that purpose.
If you really want that int i to come out higher, you need to use your arithmetic operators, or prefix to ++i.
With or without the ().
Sorry. I should have added: when you extend an interface in an interface, you have to make sure that if the super-interfaces each have methods with the same names and parameters, they also have to have the same return type or the compiler will throw an error.
This makes perfect sense if you think about it.

Originally posted by monty6:
I just can not find the answer to these question.
1. When an interface extends another interface. Can it extend more than one interface?


Yes. When you actually implement the interface, you're required to define all the methods in all interfaces that the implemented interface extends, or you get an error when compiling.



2. When an interface extend another interface. Do you have to implemnt all if the extended interface methods.


interface interface1{
public void method1();
}
interface interface2{
public void method2();
}
interface interface3 extends interface1, interface2{
public void method3();
}
public class tester implements interface3{
public void method1(){}
public void method2(){}
public void method3(){}
// ... and so on.
}



3. When an interface implement's another interface. Can it implement more than one interface?


An interface cannot implement another interface. It can only extend.



4. When an interface implement's another interface. Do you have to implemnt all if the implemented interface methods.


See above.
All four compile. Of the four, however, only the first one is 'correct' as a statement of the standard required main function.
public static void main(String[] args)
or
static public void main(String[] args)
The capitalized Main will cause a runtime error. The protected and private versions of main work. I would think that the question is to demonstrate that you know the standard protocol, though, and so my guess would be that (b), (c), and (d) would be the answers.