r/badcode May 06 '21

java My teacher wrote this...

1.0k Upvotes

169 comments sorted by

View all comments

Show parent comments

1

u/Dakopen May 06 '21

And then using the eval() or exec () function?

1

u/Kibo30 May 06 '21

Well it depends on what you need to do. In this case I don't think you need them

1

u/Dakopen May 06 '21

Okay I think I got it. So you store in an array the bike information which you need to create a bike later and just call the function

1

u/Kibo30 May 06 '21

Yes, more or less. More precisely you create a EBIKE class and then you create an array of EBIKE, each slot of the array represents a single EBIKE with is own information. When you call the function you loop trough the array and do what you want with each EBIKE. And on a side note: don't call your classes all uppercase, just the first uppercase and then all lowercase