13 Replies - 612 Views - Last Post: 18 October 2016 - 05:02 PM Rate Topic: -----

#1 owtu16  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 18-October 16

Is this a good design for a seating program for a restaurant?

Posted 18 October 2016 - 11:42 AM

Hi, I'm not displaying any code as of yet. I just want an opinion of how I am going to go about my design. I want to have two classes, one for the table and one for the customer. Tables will be linked together in a single linked list and each table will have 4 customers by default. Customers will be attached in a circular linked list to each table. I attached a picture I drew of what I'm planning to do, I just want someone's input to know if I'm approaching this problem the right way or maybe I'm overthinking it and it could be done in a simpler way. I have a circular linked list for customers because it would be "easier" to add or remove customer from a table in case it is needed.

Is This A Good Question/Topic? 0
  • +

Replies To: Is this a good design for a seating program for a restaurant?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13348
  • View blog
  • Posts: 53,162
  • Joined: 12-June 08

Re: Is this a good design for a seating program for a restaurant?

Posted 18 October 2016 - 11:45 AM

I am not sure if 'circular linked lists' is really needed, but the rest sounds reasonable.
Was This Post Helpful? 0
  • +
  • -

#3 owtu16  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 18-October 16

Re: Is this a good design for a seating program for a restaurant?

Posted 18 October 2016 - 11:46 AM

Posted Image
Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3679
  • View blog
  • Posts: 13,312
  • Joined: 08-August 08

Re: Is this a good design for a seating program for a restaurant?

Posted 18 October 2016 - 11:54 AM

Since I can't see your code I'm going to assume it's C++, in which case I'd use vectors for both. The table class would hold the number of seats for the table and a vector of tables that could be joined to the table for larger parties. You could do the same with a linked list, but then you need to manage memory, and history has shown that it's very easy/likely that a leak will occur at some point.
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5786
  • View blog
  • Posts: 19,689
  • Joined: 05-May 12

Re: Is this a good design for a seating program for a restaurant?

Posted 18 October 2016 - 11:55 AM

Unless you remove type safety, I think you'll run into trouble with your customer circular linked list where its next pointer can point to either another customer, or to a table. I suggest a single linked list. Better yet, simply use an std::vector.
Was This Post Helpful? 0
  • +
  • -

#6 jimblumberg  Icon User is offline

  • member icon

Reputation: 5285
  • View blog
  • Posts: 16,458
  • Joined: 25-December 09

Re: Is this a good design for a seating program for a restaurant?

Posted 18 October 2016 - 12:00 PM

Quote

I have a circular linked list for customers because it would be "easier" to add or remove customer from a table in case it is needed.

Easier than what? Since you're talking about C++ you really should consider using a std::vector.

Quote

Tables will be linked together in a single linked list and each table will have 4 customers by default.

Why 4 customers by default? I would think zero customers would be a better default for each table. After all when the restaurant opens it will probably have no customers, but will probably always have a certain number of tables. Also you will probably need to keep track of how many people a particular table can hold. Your tables will probably hold a different number of customers. Again why a linked list? Why not a std::vector?

Quote

I want to have two classes, one for the table and one for the customer.

The number of classes would depend on what kind of information you need to keep track of. For example when talking about customers, what specific information do you need to know about each customer? Also I would think knowing how many people are in a party would be more important to determine how you will seat this party. Remember that these customers may want to be seated at the same table. If your tables hold a different number of customers, you want to try to seat each party into the smallest possible table, whenever possible.

Jim
Was This Post Helpful? 1
  • +
  • -

#7 owtu16  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 18-October 16

Re: Is this a good design for a seating program for a restaurant?

Posted 18 October 2016 - 12:11 PM

I'm not very familiar with vectors. I thought I would need a class for the customer since I need to add some integers, booleans and other functions that will deal with the customer's request
Was This Post Helpful? 0
  • +
  • -

#8 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3679
  • View blog
  • Posts: 13,312
  • Joined: 08-August 08

Re: Is this a good design for a seating program for a restaurant?

Posted 18 October 2016 - 12:41 PM

Read this link, and the one in post #7 of that link.
Was This Post Helpful? 0
  • +
  • -

#9 Xupicor  Icon User is offline

  • Nasal Demon
  • member icon

Reputation: 456
  • View blog
  • Posts: 1,179
  • Joined: 31-May 11

Re: Is this a good design for a seating program for a restaurant?

Posted 18 October 2016 - 01:01 PM

View Postjimblumberg, on 18 October 2016 - 10:00 PM, said:

Also I would think knowing how many people are in a party would be more important to determine how you will seat this party. Remember that these customers may want to be seated at the same table. If your tables hold a different number of customers, you want to try to seat each party into the smallest possible table, whenever possible.
Also, if the party is larger than any given table - they may want to sit at multiple tables that are near each other*, so actually representing the restaurant table layout as a graph may be of use here, and make for an interesting assignment if OP never touched graphs.

But then again if OP doesn't even know how to use std::vector yet - we may just ignore that particular problem for the sake of not ramping up the difficulty too much. Not to mention if it's not in the original problem set, then it would be extra work for possible no payoff.

__
*) similarly, if the party size is smaller than smallest free table, then they might prefer to be seated separately, instead of being added to some strangers (and vice versa). Yet another problem is to seat guests at tables in such a way that they will be more or less uniformly spaced out - you don't want to have everybody clumped up in one corner with half the restaurant empty. These are all interesting for somebody learning to deal with graphs, I think. But may well go above and beyond the assignment - assuming it is an assignment.

This post has been edited by Xupicor: 18 October 2016 - 01:05 PM

Was This Post Helpful? 1
  • +
  • -

#10 jimblumberg  Icon User is offline

  • member icon

Reputation: 5285
  • View blog
  • Posts: 16,458
  • Joined: 25-December 09

Re: Is this a good design for a seating program for a restaurant?

Posted 18 October 2016 - 01:07 PM

Quote

then it would be extra work for possible no payoff.

I wouldn't necessarily say no payoff, after all learning more has payoffs all in it'self. However it sounds like keeping things simple will be a better idea in this particular case, unless the OP has omitted a great deal of information about the assignment.

Jim
Was This Post Helpful? 0
  • +
  • -

#11 Xupicor  Icon User is offline

  • Nasal Demon
  • member icon

Reputation: 456
  • View blog
  • Posts: 1,179
  • Joined: 31-May 11

Re: Is this a good design for a seating program for a restaurant?

Posted 18 October 2016 - 01:14 PM

Well, most of what I had in mind is that it might not play a role when it comes to final marks. It would have an obvious payoff in terms of new knowledge gained, that's for sure. Personally - I think it's well worth it. But I don't want to evangelize on how people should deal with their professors or spend their own damn time. : )

Starting simple won't hurt in any case - nor just being aware of these possibly pretty interesting problems being there, waiting to be conquered. ; )
Was This Post Helpful? 0
  • +
  • -

#12 owtu16  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 18-October 16

Re: Is this a good design for a seating program for a restaurant?

Posted 18 October 2016 - 03:49 PM

ok, so I went over vectors and decided that I could still have a linked list of tables and I can create an object vector for the customer class. Does that sound better?
Was This Post Helpful? 0
  • +
  • -

#13 jimblumberg  Icon User is offline

  • member icon

Reputation: 5285
  • View blog
  • Posts: 16,458
  • Joined: 25-December 09

Re: Is this a good design for a seating program for a restaurant?

Posted 18 October 2016 - 04:21 PM

Why not a vector of tables?

Jim
Was This Post Helpful? 1
  • +
  • -

#14 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5786
  • View blog
  • Posts: 19,689
  • Joined: 05-May 12

Re: Is this a good design for a seating program for a restaurant?

Posted 18 October 2016 - 05:02 PM

And a queue of parties containing vectors of customers to simulate the people waiting to get tables - assuming the restaurant does not take reservations. If it does take reservations, then a more sophisticated data structure will likely be needed, or simply co-op a priority queue and have special logic for when things get removed from the queue.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1