2 Replies - 256 Views - Last Post: 31 July 2014 - 08:46 AM Rate Topic: -----

#1 xuinkrbin.  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-July 14

Recommendations for iterating over either row or column?

Posted 31 July 2014 - 05:59 AM

Suppose I want to represent an apartment building in terms of floors and rooms with a single data object. Each floor has the same number of rooms at any given time. During the course of the program, I will need to change the number of floors occasionally and will need to change the number of rooms on each floor occasionally. (Don't worry about the building permits needed to do this.) Now, I also want to be able to iterate over either each floor (think "row") or each room (think "column"). For example, I might want to program the equivalent of "Johnson, go fix all the front doors on the 8th floor" or the equivalent of "Johnson, go fix all the front doors to room B on each floor". (Yeah, I know, for the latter I could iterate over each floor and then access room B but that doesn't feel as "clean" as being able to iterate over a separate room/column.) Does Anyone have any recommendations about how to approach this problem?

Is This A Good Question/Topic? 0
  • +

Replies To: Recommendations for iterating over either row or column?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9363
  • View blog
  • Posts: 35,172
  • Joined: 12-June 08

Re: Recommendations for iterating over either row or column?

Posted 31 July 2014 - 06:59 AM

It is not a "row and column" issue, but one of collections and objects. You would have a room object. You would have a 'floor' object that would have a collection of 'room' objects. You would then have a 'building' object that has a collection of 'floor' objects.
Was This Post Helpful? 0
  • +
  • -

#3 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1362
  • View blog
  • Posts: 4,715
  • Joined: 19-February 09

Re: Recommendations for iterating over either row or column?

Posted 31 July 2014 - 08:46 AM

If the rooms are labelled A, B, C etc., the first index is 'A' - 'A' which is 0, and 'B' - 'A' is 1.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1