¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: [TDD] Test Driven Development By Example Query


 

¿ªÔÆÌåÓý

Ah yes! Wonderful thanks!


On 11 Nov 2014, at 17:18, Keith Ray keith.ray@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:

?

Think classes, not objects. The Equals method defined by class Franc can access member variables of class Franc.


Same as C++.

--
C. Keith Ray
* (650) 533-6535
*?
*



On 2014 Nov 11, at 8:25 AM, Aaron Carey aaronccarey@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:


Hi,

I'm sorry this may be a rather stupid question, but it's been bugging me as I'm reading through Kent Beck's book 'Test-Driven Development By Example'

I think it might be my understanding of Java (I have a C++/Python background) but I was really hoping someone could clear something up!

This happens a few times in the book so far, but here's an example:

on Page 24, there's a Franc class which defines equals and sets the amount variable as a private int. Within the equals method a Franc object passed into the method has the amount variable queried. How does this work? I thought private variables couldn't be accessed outside of the object, but here you query it from another object? Is there some sort of friend class behaviour?

Thanks so much for your help!

class Franc {
? ? private int amount;

? ? Franc(int amount) {
? ? ? ? this.amount= amount;
? ? }

? ? public boolean equals(Object object) {
? ? ? ? Franc franc= (Franc) object;
? ? ? ? return amount == franc.amount;
? ? }
}


Join [email protected] to automatically receive all group messages.