Forums Register Login

Variable passing between class

+Pie Number of slices to send: Send
Im trying to pass some variable between classes, but it is not going to let me because of the "actual and formal argument lists differ in length"

say I got this code here





if I pass int spd from blueBike to redBike it should give me an error. So how can I just pass one variable from blueBike to redBike? is that even possible? (redBike is expecting another method to pass to it the gear setting)
+Pie Number of slices to send: Send
Why don't you have 2 methods?

+Pie Number of slices to send: Send
 

jo buger wrote:Im trying to pass some variable between classes, but it is not going to let me because of the "actual and formal argument lists differ in length"

say I got this code here





if I pass int spd from blueBike to redBike it should give me an error. So how can I just pass one variable from blueBike to redBike? is that even possible? (redBike is expecting another method to pass to it the gear setting)




Always follow naming conventions Jo. Class names always start with capital case alphabet. So do the constructor names. So your class and constructor names should be BlueBike and RedBike. If you follow simple steps/rules correctly, most of your mistakes will be eliminated. Get your concepts clear first so that you will think correctly. That is why I said- Read the Kathy-Bates book.

+Pie Number of slices to send: Send
And yes, I forgot one major point, WELCOME TO JAVA RANCH!!
+Pie Number of slices to send: Send
 

jo buger wrote:say I got this code here...


First, I think you need to explain what you're trying to do, because I suspect you're overthinking this by a country mile.

So: Given a red bike and a blue bike - which presumably are both subtypes of a Bike (although even that is open to question) - what do you want to do?

Winston
+Pie Number of slices to send: Send
Try Variable Arguments concept. I hope it will fulfill the needs..
1
+Pie Number of slices to send: Send
 

Winston Gutkowski wrote: . . . So: Given a red bike and a blue bike - which presumably are both subtypes of a Bike (although even that is open to question) - . . .

I would certainly question that. I would suggest that colour is an attribute of a bicycle and creating BlueBike or RedBike classes is dubious to say the least.
RacingBike TouringBike TandemBike and MountainBike sound like better types of subclass.
+Pie Number of slices to send: Send
 

Campbell Ritchie wrote:

Winston Gutkowski wrote: . . . So: Given a red bike and a blue bike - which presumably are both subtypes of a Bike (although even that is open to question) - . . .

I would certainly question that. I would suggest that colour is an attribute of a bicycle and creating BlueBike or RedBike classes is dubious to say the least.
RacingBike TouringBike TandemBike and MountainBike sound like better types of subclass.



I would have to agree on that as I am an avid cyclist myself. I also have an object of MountainBike and RacingBike each with me at home. (MountainBike.name = "Schwinn" & RacingBike.name = "OrbeaTTG")
+Pie Number of slices to send: Send
But are they red or blue?
+Pie Number of slices to send: Send
 

Campbell Ritchie wrote:But are they red or blue?



Hahahahaha!! LMAO!! Schwinn.color = "blue" and OrbeaTTG.color = "white"
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 823 times.
Similar Threads
Initializing Instance Members
Error when using package
Encapsulation and getter&setter methods
It compiled but couldn't run,help me make it run
Threading
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 20:23:59.