Place under the GPL.
[restaurants.git] / restaurants.pl
blobd1f4da3449dd6c180c2f4e281a4ee14483fda9d0
1 #!/usr/bin/perl
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 use warnings;
17 use strict;
19 #use Getopt::Long;
21 #my $quick = 0;
22 #GetOptions('quick' => \$quick,
23 #'quiet+' => \$quiet,
24 #'verbose+' => \$verbose);
25 #print $quick;
26 #exit(0);
28 print "Karen's Restaurant Selector\n\n";
30 my @restaurant_list = (
31 {name => 'Akai Hana', genre => 'Japanese'},
32 {name => 'Athens', genre => 'Greek'},
33 {name => 'Baja Fresh', genre => 'Mexican'},
34 {name => 'Bamboo Fresh', genre => 'Vietnamese'},
35 {name => 'Boston Market', genre => 'Deli'},
36 {name => 'Burger King', genre => 'Fast Food'},
37 {name => 'Brett\'s BBQ', genre => 'American'},
38 {name => 'California Pizza Kitchen', genre => 'American'},
39 {name => 'Carl\'s Jr.', genre => 'Fast Food'},
40 {name => 'Cheeburger Cheeburger', genre => 'American'},
41 {name => 'Chili\'s', genre => 'American'},
42 {name => 'China Fun', genre => 'Chinese'},
43 {name => 'Coco\'s', genre => 'American'},
44 {name => 'Daphne\'s', genre => 'Greek'},
45 {name => 'El Pollo Loco', genre => 'Fast Food'},
46 {name => 'El Torito\'s', genre => 'Mexican'},
47 {name => 'Elephant Bar', genre => 'American'},
48 {name => 'Fire House Pizza', genre => 'American'},
49 {name => 'Grazianos', genre => 'Italian'},
50 {name => 'Hanaoka', genre => 'Japanese'},
51 {name => 'In-N-Out', genre => 'Fast Food'},
52 {name => 'Island\'s', genre => 'American'},
53 {name => 'Jack In The Box', genre => 'Fast Food'},
54 {name => 'Joey\'s BBQ', genre => 'American'},
55 {name => 'King Taco Loco Donalds in-n-out a Box Jr\'s', genre => 'Fast Food'},
56 {name => 'L&L Hawaiian Barbecue', genre => 'American'},
57 {name => 'Mama Cella\'s', genre => 'Italian'},
58 {name => 'Marie Callender\'s', genre => 'American'},
59 {name => 'McDonalds', genre => 'Fast Food'},
60 {name => 'Kelly\'s Public House', genre => 'American'},
61 {name => 'Olive Garden', genre => 'Italian'},
62 {name => 'Panda Buffet', genre => 'Chinese'},
63 {name => 'Panera', genre => 'Deli'},
64 {name => 'Passage To India', genre => 'Indian'},
65 {name => 'Pat and Oscars', genre => 'Italian'},
66 {name => 'Pearl', genre => 'Chinese'},
67 {name => 'Pegasus', genre => 'Greek'},
68 {name => 'Pei Wei', genre => 'Chinese'},
69 {name => 'Pho', genre => 'Vietnamese'},
70 {name => 'Pick Up Stix', genre => 'Chinese'},
71 {name => 'Quick Wok', genre => 'Chinese'},
72 {name => 'RB Sushi', genre => 'Japanese'},
73 {name => 'Rubio\'s', genre => 'Mexican'},
74 {name => 'Souplantation', genre => 'American'},
75 {name => 'Spices Thai', genre => 'Thai'},
76 {name => 'Stir Fresh', genre => 'Mongolian'},
77 {name => 'Subway', genre => 'Deli'},
78 {name => 'Taco Bell', genre => 'Fast Food'},
79 {name => 'ThaiGo', genre => 'Thai'},
80 {name => 'ToGo\'s', genre => 'Deli'},
81 {name => 'Wahoo\'s', genre => 'Mexican'},
82 {name => 'Wings N Things', genre => 'American'},
83 {name => '4S Ranch (Outside Patio)', genre => 'Mix'}
86 my $number_of_restaurants = scalar(@restaurant_list);
87 my $restaurant_name;
89 my $valid_choice = 0;
90 my $choice1 = 0;
91 print "[1] Choose from all restaurant list.\n";
92 print "[2] Choose from quick restaurant list.\n";
93 print "[3] Choose from cuisine list.\n";
94 print "[0] Exit Program.\n";
97 print "What is your choice (type a number and hit enter)? ";
98 chomp($choice1 = <STDIN>);
99 if($choice1 !~ /\d$/ || $choice1 < 0 || $choice1 > 3)
101 print "Invalid choice. Please choose between 0 and 3.\n";
102 } else {
103 $valid_choice = 1;
105 } while(0 == $valid_choice);
107 if(0 == $choice1)
109 exit(0);
111 elsif(1 == $choice1)
113 my $restaurant_number = rand $number_of_restaurants;
114 # Randomly pick a restaurant
115 $restaurant_name = $restaurant_list[$restaurant_number]{'name'};
117 elsif(2 == $choice1)
119 my @quick_restaurant_list;
120 # Add all fast food restaurants
121 for(my $i = 0; $i < $number_of_restaurants; $i++)
123 if('Fast Food' eq $restaurant_list[$i]{'genre'})
125 push @quick_restaurant_list, $restaurant_list[$i]{'name'};
128 # Add hard coded quick restaurants
129 push @quick_restaurant_list, 'Boston Market';
130 push @quick_restaurant_list, 'China Fun';
131 push @quick_restaurant_list, 'Fire House Pizza';
132 push @quick_restaurant_list, 'Grazianos';
133 push @quick_restaurant_list, 'Hanaoka';
134 push @quick_restaurant_list, 'Pat and Oscars';
135 push @quick_restaurant_list, 'Pick Up Stix';
136 push @quick_restaurant_list, 'Quick Wok';
137 push @quick_restaurant_list, 'Souplantation';
138 push @quick_restaurant_list, 'Spices Thai';
139 push @quick_restaurant_list, 'ThaiGo';
141 # Randomly pick a restaurant
142 $restaurant_name = $quick_restaurant_list[rand @quick_restaurant_list];
144 elsif(3 == $choice1)
146 # Create a list of cuisines from the restaurant list.
147 my @cuisine_list;
148 for(my $i = 0; $i < $number_of_restaurants; $i++)
150 my $found = 0;
151 for(my $j = 0; $j < scalar(@cuisine_list); $j++)
153 if($cuisine_list[$j] eq $restaurant_list[$i]{'genre'})
155 $found = 1;
158 if(0 == $found)
160 push @cuisine_list, $restaurant_list[$i]{'genre'};
163 @cuisine_list = sort(@cuisine_list);
165 # Print out a list of cuisines and ask user to select 1.
166 my $i = 1;
167 foreach my $cuisine(@cuisine_list)
169 print "[$i] $cuisine\n";
170 $i++;
172 print "Which genre of cuisine (type a number and hit enter)? ";
173 chomp(my $cuisine_choice = <STDIN>);
175 # validate cuisine_choice
176 if(1 > $cuisine_choice or $cuisine_choice > scalar(@cuisine_list))
178 die "Yo homeboy, $cuisine_choice ain't on the list.\n";
181 # Create an array with restaurants that are of genre $cuisine_choice
182 my $cuisine_genre = $cuisine_list[$cuisine_choice - 1];
183 my @cuisine_restaurant_list;
184 for(my $i = 0; $i < $number_of_restaurants; $i++)
186 if($cuisine_genre eq $restaurant_list[$i]{'genre'})
188 push @cuisine_restaurant_list, $restaurant_list[$i]{'name'};
192 # Randomly pick a restaurant
193 $restaurant_name = $cuisine_restaurant_list[rand @cuisine_restaurant_list];
195 else
197 die "Yo homeboy, $choice1 ain't on the list.\n";
200 print $restaurant_name . " is as good a place as any.\n";