HELP WITH CONFUSING HW! O_O

Hi, I would really apreciate the help of anyone, i just need guidance, this Professor likes to confuse students! He is teaching us C++ but never mention a word about HTML, but that doesnt concern me much i just want to know what he really wants us to do, below is the description of what we need to do but its just really confusing. Thanks in advance! :D



1. Create an HTML table class. When an HTML table object is created you specify the number
of rows and columns in the table. Once a table is created you can put a string, number or objects
with a to_string method into any location (cell) in the table. If you create a table with 4
rows and 3 columns then you could put a string in row 1, column 2 and a float in row 2, column
1. However if you try to add an item to a location that does not exist (row 3 column 4 in the
above example) an exception is raised. After creating a HTML table you can add more rows
and columns to the table. Any location or cell in the table can be marked as bold. The table has
a to_string method that returns the table in HTML format. The contents of any cell marked at
bold will be rendered as bold. Here is an example.
<table>
! <tr>
! ! <td>1</td> <td><b>2</b></td> <td>3</td>
! </tr>
! <tr>
! ! <td>4</td> <td>5</td> <td>6</td>
! </tr>
</table>
Note that the spaces between tags are optional. So the above is the same as:
<table><tr><td>1</td><td><b>2</b></td><td>3</td></tr>
<tr><td>4</td><td>5</td> <td>6</td></tr></table>
2. The context for this problem is an on-line grader program. The grades for the course are
stored in a file called grades.txt. A student will logon to a web site. The web site code will call
your code and provide the name of the student. You code returns the HTML for the page continuing
the student's grades. The grades will be in an html table. The first row of the table contain
the labels for the columns. The first row elements should be in bold. The second row will
contain the name and the scores for the given person. The third row contains maximum points
for each column. The rest of the table would contain the scores for the entire course. However
in each column the scores would be sorted. Given the following sample file
Name,Exam,C Assignment,C++ Assignment
Whitney,79,82,69
Olson,55,100,92
Shah,89,91,94
Max Points,90,100,100
And the input name "Olson" the table without the HTML tags would look like:
Name,Exam,C Assignment,C++ Assignment
Olson,55,100,92
Max Points,90,100,100
1,89,100,94
2,79,91,92
3,55,82,69
So with the input name of "Olson" your code will return the following:
<html lang="en">
<head>
! <meta http-equiv="content-type" content="text/html; charset=utf-8">
! <title>Sample Output</title>
</head>
<body>
<table>
! <tr>
! ! <td><b>Name</b></td> <td><b>Exam</b></td> <td><b>C Assignment</
b></td> <td><b>C++ Assignment</b></td>
! </tr>
! <tr>
! ! <td>Olson</td> <td>55</td> <td>100</td> <td>92</td>
! </tr>
! <tr>
! ! <td>Max Points</td> <td>90</td> <td>100</td> <td>100</td>
! </tr>
! <tr>
! ! <td>1</td> <td>89</td> <td>100</td> <td>94</td>
! </tr>
! <tr>
! ! <td>2</td> <td>79</td> <td>91</td> <td>92</td>
! </tr>
! <tr>
! ! <td>3</td> <td>55</td> <td>82</td> <td>69</td>
! </tr>
</table>
</body>
</html>
let me try to answer part-1. Start small and just start with one requirements and keep adding new stuff.

get the inputs for row and columns. So, it can be 4x3; save them in the class;
Create a buffer of that size or may be use std::containers;
start taking inputs from the user for each row x column. keep feeding all this into the class;
once the user wants to finish, flush the table in a file like this:


1
2
3
4
5
6
7
8
9
10
11
start table tag
	loop for each row
		start row tag
		loop for each column
			start column tag
				output row x column value from buffer
			end column tag
		end column loop
		end row tag
	end row loop
end table tag

Last edited on
Topic archived. No new replies allowed.