During this lab session:
This activity helps students develop the following skills, values and attitudes: ability to analyze and synthesize, capacity for identifying and solving problems, and efficient use of computer systems.
The lab activities can be developed individually or in pairs.
The lab report must be developed individually.
Create a Ruby on Rails application called pascal
.
Inside this application, generate a controller called
triangle
with two actions: input
and
draw
.
The Ruby source file triangle_controller.rb
must
start with a comment containing the lab's title, date, and the
authors' personal information. For example:
# Lab 9: Pascal's Triangle # Date: 29-Mar-2011 # Authors: # 456654 Anthony Stark # 1160611 Thursday Rubinstein
Create a layout file for the application with the following content:
<!DOCTYPE html> <html> <head> <%= stylesheet_link_tag :all %> <%= javascript_include_tag :defaults %> <%= csrf_meta_tag %> <title><%= yield :title %></title> </head> <body> <%= yield :layout %> <hr/> <p class="footer"> Software Design and Architecture </p> </body> </html>
Create a stylesheet file with the following content:
body { background: #FFFFFF; color: #000080; font-family: sans-serif; font-size: medium; margin: 20px; } hr { border: 0; color: #B0C4DE; background-color: #B0C4DE; height: 1px; } table { border-collapse: collapse; border: 1px solid #000000; padding: 0px; margin-bottom: 10px; color: #000000; background: #E6E6FA; } td { border: 1px solid #000000; padding: 10px; text-align: center; } th { border: 1px solid #000000; padding: 10px; color: #008080; background: #B0E0E6; } .footer { font-size: 70%; color: #B0C4DE; text-align: center; }
Modify the input.html.erb
file so that it contains
a web form with a text field that asks for a number n
between 0 and 99. It should look like this:
When the submit button labeled "Send" is pressed, the action
draw
should be requested.
The draw
action and view must work together in
order to display the diagonals 0 to n of Pascal's
triangle (using the <table>
,
<tr>
and <td>
tags).
This is how the triangle should be built: the first row and column are composed of ones; all other elements are computed by adding the element immediately above plus the element immediately to the left. In the resulting table, all cells that are not part of the triangle should be left blank. For example, for n = 5, the output should look something like this:
To hand in your individual lab work, follow these instructions.
lab9_report_A0MMMMMMM.tex
, where A0MMMMMMM
is your student ID. From your LaTeX source, generate the
corresponding PDF file. That file should be called
lab9_report_A0MMMMMMM.pdf
. Place these two files in the
pascal
directory.
pascal
directory. Call this file pascal.zip
.
Due date is Monday, April 4.
This activity will be evaluated using the following criteria:
50% | Implementation of functional requirements. |
---|---|
50% | Lab report. |
DA | The program and/or report was plagiarized. |