- Fork this repo
- Clone your fork
- Fill in your answers by writing in the appropriate area, or placing an 'x' in the square brackets (for multiple-choice questions).
- Add/Commit/Push your changes to Github.
- Open a pull request.
Note: only place your answer between backticks. Don't modify the backticks, or the language specifier after them.
Define a method called offerRose
, which should take one argument named person.
When called, the method should puts
, "Would you take this rose and help out
an old beggar, X?", where X is the person passed into the method.
Demonstrate calling the method with an argument of "young prince".
Write your code here:
# code here
Assume the following hash:
town = {
residents: ["Maurice", "Belle", "Gaston"],
castle: {
num_rooms: 47,
residents: "Robby Benson",
guests: []
}
}
Using Ruby, remove Belle from the town residents, and add her to the list of guests in the castle.
Write your code here:
# code here
Assume you have an array of strings representing friend's names:
friends = ["Chip Potts", "Cogsworth", "Lumière", "Mrs. Potts"]
Using .each
AND string interpolation, produce output (using puts
) like so:
Belle is friends with Chip Potts
Belle is friends with Cogsworth
Belle is friends with Lumière
Belle is friends with Mrs. Potts
Write your code here:
# code here
Describe what an ERD is, and why we create them for applications. Also give an example what the attributes and relationships might be for the following entities (no need to draw an ERD):
- Genie
- Lamp
- Person
- Pet
Your answer:
Replace this with your answer
Describe what a schema is, and how we represent a one-to-many relationship in a SQL database. If you need an example, you can use: people and wishes (one-to-many).
Your answer:
Replace this with your answer
Assume:
- Your database two working tables,
genies
andlamps
. - You have a working connection to the database for ActiveRecord.
- You have active record models defined for
Genie
andLamp
, and the relationships between the two are set up in Active Record.
- Lamps have one property,
wishes_remaining
, and genies have one property,name
.
Write code to do the following:
- Create a lamp with 3 wishes remaining and a genie named 'Genie'
- Create a relationship between 'Genie' and the lamp.
- Update the lamp so it only has one wish left.
- Oh no... Jafar has Aladdin! Thankfully he's wished to become a genie himself!
- Create a new Genie named 'Jafar' and put him in a new lamp with 3 wishes left.
- Free the good Genie by setting his lamp to
nil
Write your code here:
# code here
The Chinese Emperor needs an application to help him manage his warriors.
Describe to him what a RESTful route is, and list what the seven RESTful routes would look like for such an application.
Your description:
Replace this with your answer
Your routes:
The ancestors have provided an example of one route; you do the other six!
GET '/warriors/:id'
* This is the show route, which finds a warrior by ID, and displays information about that warrior.
Replace this with your answer
Assume:
- Warrior is an ActiveRecord model, with a 'name' attribute.
- You have a Sinatra
app.rb
(or similar file), that defines the following route:
get '/warriors' do
@warriors = Warrior.all
erb :"warriors/index"
end
Write what an example ERB file (aka view) might look like to list all the warriors:
Write your code here (NOTE: syntax highlighting doesn't work for ERB in markdown files, so ignore the colors!):
<!-- code here -->