Program using Ruby

Please help me with the program below. I do not know where to start.
Please please help me.

Write a program that can be used by a small theater to sell tickets.
The theater auditorium has 15 row of seats with 30 seats in each row.
The program should display a screen that show which seats are available
and which are taken.
Seats taken use *, seats available use #

When a program begins it should ask the user to enter the seat price for
each row. The prices can be stored in a separate array.(alternatively
the price can read from a file.)

Once price entered the program should display a seating chart. The user
may enter the row and seat number for tickets being sold. Every time a
tickets or group of tickets is purchased the program should display the
total ticket prices and update the seating chart.

The program should keep a total of all ticket sales. The user should be
given an option of viewing this amount.

The program should give the user an option to see a list of how many
seats have been sold, how many available in each row, and how many seats
are available in the entire auditorium.

input validation when tickets are being sold, do not accept row or seat
numbers that do not exist. When someone request a particular seat the
program should make sure seat is available before it is sold.

Do you have *anything *so far?

I have somewhat an idea of how to start this but I am just a Ruby
newbie.
Maybe starting setting up the rows up by arrays?
Row1 [1…30]
Row2[1…30]

Let us know what you have so far. I’m curious what to hear what the
others
think. I will probably try it out once I finish some more Ruby
tutorials.

Regards

Sounds like a homework assignment.

I’ll give you one possible way to store the data - use a hash with a
row/seat key instead of an array. It may make the code easier to read.

– Matt
It’s not what I know that counts.
It’s what I can remember in time to use.

I do not know where to start.

Well, of course there are different ways to do it.
Maybe you could start like this.

puts “_”*75
3.times{puts " “*75+”|"}
puts " “*68+“EXIT”+[0x2b00].pack(“U”)
puts " “*76+”/”
puts " “*75+”/"
3.times{puts " “*75+”|"}

seats = (0…15).map{Array.new(30,"#")}
seats[5][2] = “" # sample input
seats[6][3] = "
” # sample input
seats.each_index do |x|
puts " “(5 + x%2) + seats[x].join(" ") + " "(11-x%2)+”|"
puts " “*75+”|"
end

Harry

Matt L. wrote in post #1123105:

Sounds like a homework assignment.

I’ll give you one possible way to store the data - use a hash with a
row/seat key instead of an array. It may make the code easier to read.

– Matt
It’s not what I know that counts.
It’s what I can remember in time to use.

Yes. This is a project. But my professor did not teach us this program
language. Im learning online with “man with code” but it doesn’t help
with this particular project. If you can help it would be great…Can
you explain "hash a little more. Maybe how to start it?

chuong vu wrote in post #1123104:

Do you have *anything *so far?

I have somewhat an idea of how to start this but I am just a Ruby
newbie.
Maybe starting setting up the rows up by arrays?
Row1 [1…30]
Row2[1…30]

Let us know what you have so far. I’m curious what to hear what the
others
think. I will probably try it out once I finish some more Ruby
tutorials.

Regards

I have this to start …
class Theater
attr_accessor :seating, :pricing;

def initialize(seating=" " )
@seating = seating
end

def initialize(pricing=$20)
@pricing = pricing
end
end

and this part…

def
x= selections
puts ("Enter a number for options: ")
number = integer(gets)
case number
when 1
x = "You have selected to see how many seats sold. "
when 2
x = "You have selected to see how many seats are available. "
when 3
x = "You have selected how many seats are in the entire auditorium. "
else
x = "Please select options 1, 2, or 3. "
end
Print(x)
Print "what seat(s) would you like to purchase? "
if seats == available
puts "your purchases are eligible. "
else
puts "Sorry these seats are already sold. "
end

Hash is a PAIR of data.

start with getting it to read the file. =)

On Thu, 3 Oct 2013, Kristina G. wrote:

Im not going to lie. Im completely lost when it comes to this
programming language. I have 1 more day and we are moving to another
language… Waste of time. But I need to maintain a good grade. Please
help me to understand this… My first language was C++ then java…
this is completely different and I probably will not use it.

That’s an oboxious situation to be in. Your best bet is to write it
like
you would in C. There are good references available via ruby-lang.org.

I would probably spend a couple of hours writing it and use a very
different style than you are going to be able to manage with such a
tight
deadline. Ruby has arrays and various types of output formating that
shouldn’t be to alien. You would have been better off if you already
knew
awk or perl.

– Matt
It’s not what I know that counts.
It’s what I can remember in time to use.

Kristina G.,

If you have some experience with other languages this can be
straitghforward (or not :wink: )
There’s a good free reference that you can use (although old and
little outdated, it’s still valuable) and it is
http://www.ruby-doc.org/docs/ProgrammingRuby/
Just go through the data types and constructs (flow control) you need
to make your program.

Abinoam Jr.

Im not going to lie. Im completely lost when it comes to this
programming language. I have 1 more day and we are moving to another
language… Waste of time. But I need to maintain a good grade. Please
help me to understand this… My first language was C++ then java…
this is completely different and I probably will not use it.

A couple of years ago, I wrote a similar front-end app in jQuery/CSS. I
started with some example code from an airline seat booking app. The CSS
came in handy for manipulating the color of the seat icons as an
indication of status (available, reserved, sold). Since I’m trying to
get up to speed with Ruby, I’d be hard pressed to port it (ideally to
Rails) within a day. As a previous reader mentioned, however, you should
be able to do it, especially since your project only requires a command
line interface. Here’s a link to the later versions of the Ruby
Programming book: http://it-ebooks.info/ . Simply enter the title into
the search control on the main page to list the latest versions.
– Haig

Ruby has C++ style as well. Even some javaisms made it into the
language.
There really should be no barrier to writing the program as Ruby is a
language without so called strict rules provided by either operating
system
languages or so called academic languages.

Break down the project and program it one part at a time.

Looks like you need to have input from the user. start with locating how
you would go about creating a program in ruby to scan input from the
user.

Haig D. wrote in post #1123369:

A couple of years ago, I wrote a similar front-end app in jQuery/CSS. I
started with some example code from an airline seat booking app. The CSS
came in handy for manipulating the color of the seat icons as an
indication of status (available, reserved, sold). Since I’m trying to
get up to speed with Ruby, I’d be hard pressed to port it (ideally to
Rails) within a day. As a previous reader mentioned, however, you should
be able to do it, especially since your project only requires a command
line interface. Here’s a link to the later versions of the Ruby
Programming book: http://it-ebooks.info/ . Simply enter the title into
the search control on the main page to list the latest versions.
– Haig

By chance do you have the program you used for the Airline seat booking
app. I think I just need an example of something else. Can anyone help
with this… Maybe an example of something else not this./ But anyone
can feel free to add to my program.

Harry K. wrote in post #1123123:

I do not know where to start.

Well, of course there are different ways to do it.
Maybe you could start like this.

puts “_”*75
3.times{puts " “*75+”|"}
puts " “*68+“EXIT”+[0x2b00].pack(“U”)
puts " “*76+”/”
puts " “*75+”/"
3.times{puts " “*75+”|"}

seats = (0…15).map{Array.new(30,"#")}
seats[5][2] = “" # sample input
seats[6][3] = "
” # sample input
seats.each_index do |x|
puts " “(5 + x%2) + seats[x].join(" ") + " "(11-x%2)+”|"
puts " “*75+”|"
end

Harry

whats the above section display… the outline of the program? I saw it
had an exit and border. Really cool!!! Next I have …

def
x= selections
puts ("Enter a number for options: ")
number = integer(gets)
case number
when 1
x = "You have selected to see how many seats sold. "
when 2
x = "You have selected to see how many seats are available. "
when 3
x = "You have selected how many seats are in the entire auditorium. "
else
x = "Please select options 1, 2, or 3. "
end
Print(x)
Print "what seat(s) would you like to purchase? "
if seats == available
puts "your purchases are eligible. "
else
puts "Sorry these seats are already sold. "
end

how would I link this?