It's just something I want to do for now to make simple and basic. Could you do what I'm trying to do without using all that array stuff?
17 Replies - 549 Views - Last Post: 13 October 2011 - 10:13 AM
#16
Re: Using the 'new' keyword/calling method from another class
Posted 13 October 2011 - 10:04 AM
#17
Re: Using the 'new' keyword/calling method from another class
Posted 13 October 2011 - 10:07 AM
Sure- the way you are doing it will work; it's just a pain because you have to write more code for each variable. Arrays just make your life easier. You can write more code if you want to though. I highly recommend learning arrays, though.
#18
Re: Using the 'new' keyword/calling method from another class
Posted 13 October 2011 - 10:13 AM
Yes it is possible, but as much as you want to keep things simple and basic, this is probably the more simpler way to do it, may look like more work but it isn't that hard where with what you are wanting to do requires keeping track of restrictions and having a lot of if statements for checks etc. It isn't the most basic thing I understand. I am all for doing things one step at a time and learning to walk before you run, but this really is a basic fundamental learning opportunity. By doing it the way I suggested you get many benefits including and not limited to learning how to work a class with another class, how object interact with methods in other classes, good OOP design,and most importantly not having magic numbers, which are hardcoded like creating an array with length of 3 and only 3. Would be a fully functional program and teach you how to handle operations of multi-class projects that you will need to know for future projects.
It is possible to do it your way, but I really encourage you to do it the other way that was suggested.
Edit - Here is an example of what I was talking about. The basis is you have an Item, ShoppingCart to hold the items, and a Driver class Shop
It is possible to do it your way, but I really encourage you to do it the other way that was suggested.
Edit - Here is an example of what I was talking about. The basis is you have an Item, ShoppingCart to hold the items, and a Driver class Shop
Spoiler
This post has been edited by Fuzzyness: 13 October 2011 - 11:24 AM
|
|

New Topic/Question
Reply




MultiQuote





|