Share this post! | Vote this! |
|
In this tutorial, we will be covering how to use Classes and Objects instead of Parallel Arrays. In order to teach
students how to use arrays, many instructors give assignments requiring to use two or three arrays in parallel to
represent attributes in what should be classes. While this type of assignment allows students to gain confidence
when using arrays, this type of approach becomes very cumbersome to use and difficult to manage, especially as the number of elements stored increases in size and more so as the use of resizable collections like ArrayLists come into play.
So let's go ahead and start out with a standard inventory program that uses parallel arrays to store price, quantity and name. This program will display a menu using a JOptionPane window requesting input for adding inventory, updating a current item's status, displaying the inventory, and quitting. If the user wants to update an item, we will display another menu asking for the index of the item to change. more...
students how to use arrays, many instructors give assignments requiring to use two or three arrays in parallel to
represent attributes in what should be classes. While this type of assignment allows students to gain confidence
when using arrays, this type of approach becomes very cumbersome to use and difficult to manage, especially as the number of elements stored increases in size and more so as the use of resizable collections like ArrayLists come into play.
So let's go ahead and start out with a standard inventory program that uses parallel arrays to store price, quantity and name. This program will display a menu using a JOptionPane window requesting input for adding inventory, updating a current item's status, displaying the inventory, and quitting. If the user wants to update an item, we will display another menu asking for the index of the item to change. more...
0 comments:
Post a Comment