联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> javajava

日期:2019-04-07 10:23

Due before: 11:59 PM (before Midnight) on Wed April 10 2019

Page 1 of 6

Introduction to Systems Programming (Systems I)

Homework #6

Due: Wednesday April 10 2019 before 11:59 PM

Email-based help Cutoff: 5:00 PM on Tuesday April 9 2019

Maximum Points: 25

Submission Instructions

This homework assignment must be turned-in electronically via Canvas. Ensure your

program compiles (without any warnings or style errors) successfully. Ensure you have

tested operations of your program as indicated. Once you have tested your

implementation, upload just the 1 source file onto Canvas via the CODE plug-in.

1. The Movie.h and Movie.cpp modified as part of this homework

2. The homework6.cpp C++ source file modified for this homework.

General Note: Upload each file associated with homework (or lab exercises) individually

to Canvas. Do not upload archive file formats such as zip/tar/gz/7zip/rar etc.

Objective

The objective of this homework is to:

Develop a Common Gateway Interface (CGI) program

Process inputs with URL-encoding

Run SQL queries on a database and process results

Work with a simple C++ class to manage results from a database.

Grading Rubric:

The program submitted for this homework must pass necessary base

case test(s) in order to qualify for earning any score at all.

Programs that do not meet base case requirements or just skeleton

code will be assigned zero score!

Program that do not compile, have even 1 method longer than 25

lines, or just some skeleton code will be assigned zero score.

-1 Points: for each warning generated by the compiler.

NOTE: Violating CSE programming style guidelines is a compiler error! Your

program should not have any style violations reported in NetBeans when you

compile it.

Due before: 11:59 PM (before Midnight) on Wed April 10 2019

Page 2 of 6

Starter Code:

Movie.h, Movie.cpp: For this homework you are supplied with a Movie

class. You may modify these 2 files as needed. Review the

Movie::printAsHtml method. You must use this printAsHtml method

to print Movie information (if you don't use this method to print Movie

information you automatically get zero for this homework).

homework6.cpp: For convenience you are supplied with a starter code with

some of the HTML formatting information to streamline printing results in

HTML.

hw6.html and movies.css: Do not modify or submit these 2 files.

Optionally, you can use these 2 files to setup your own website (to showcase your

work for jobs/internships) in your public_html using the procedure from prior

labs.

Background

A Movies table has been created and populated with information about movies. The

structure of the table is shown below:

mysql> desc Movies;

+---------+--------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+---------+--------------+------+-----+---------+-------+

| id | int(8) | NO | PRI | NULL | |

| title | varchar(256) | NO | MUL | NULL | |

| year | int(4) | NO | MUL | NULL | |

| genres | varchar(128) | NO | | NULL | |

| imdb_id | int(9) | NO | | NULL | |

| rating | float(7,5) | NO | | NULL | |

| raters | int(6) | NO | | NULL | |

+---------+--------------+------+-----+---------+-------+

In this homework you will be developing a custom C++ program that can find movies

matching one-or-more of the following conditions specified by the user:

1. title: If this input is specified (i.e., not an empty string) then this specifies the

partial (i.e., substring) title for the movie the user is interested in.

2. genre: If this input is specified (i.e., not an empty string) then this specifies a

partial (i.e., substring) for the genre for the movie the user is interested in.

3. startYear: If this input is specified (i.e., not an empty string) then this

specifies the earliest year to search for movies. For example, if

startYear=2000, then return only movies with year >= 2000.

4. edYear: If this input is specified (i.e., not an empty string) then this specifies

the latest year to search for movies. For example, if endYear=2016, then return

only movies with year <= 2016.

Note: You may assume at least one of the above inputs will be specified. Each of the

above inputs restricts the scope of the search. For example, if title=atri,

genre="Anim", startYear=1990, and endYear=2016, then the search is for a

movie whose title contains the substring "atri" and genre contains the substring

"anim" and year is >= 1990 and year <= 2016. If any of the inputs are not

specified, then the corresponding restriction is not applicable.

Due before: 11:59 PM (before Midnight) on Wed April 10 2019

Page 3 of 6

Demonstration site

An example website is available at http://os1.csi.miamioh.edu/~raodm/hw6/hw6.html.

You can use the above website to form a stronger mental model on the expected userexperience

for his assignment.

Homework Assignment

Develop a CGI-bin compatible C++ program that can process 1-line of input in the

following manner:

Base case: The program should extract the title value and print movies

whose title contains the specified substring. 15 points

Extra functionality #1: If genre is specified, the program should print

movies whose genre contains the specified substring. The program

should handle cases where the title or genre may or may not be specified.

8 points

Extra functionality #2: If startYear or endYear inputs are

specified then the program should restrict movies to those years

appropriately.

7 points

Tips:

1. First play with the demo website using sample inputs and outputs to ensure you

form a good mental model of the operation.

2. Use the solutions for lab exercises as reference to implement the necessary

functionality.

3. Needless to add you should URL-decode all values input via CGI.

4. Remove any trailing newline ('\n') characters in numerical inputs. Otherwise

you may get errors when calling std::stoi.

5. Use SQL LIKE clause to search for substrings.

6. Think about using if-statements to add additional conditions to your SQL query

7. Use bind variables to streamline your query. Keep in mind you can specify more

bind variables in the store() statement than used. For example, even though your

query may only have %1 as the only bind variable, you can still call

query.store(year, genre, startYear, endYear); with 4

variables.

8. Using the lab exercises as reference, develop a program with hardcoded values

to test the operations of the above store method. Developing test program is the

best way to improve your understanding. This type of learning (i.e., building

small test programs) is a key expectation in jobs and internships.

9. The above feature enables you have just 1 SQL statement to develop this

program, thereby making this assignment an cinch.

10. You will need to add a constructor or setter methods to the supplied Movie class

to set values in instance variables.

11. This would be a good project to showcase for jobs after you add more features of

your own.

Due before: 11:59 PM (before Midnight) on Wed April 10 2019

Page 4 of 6

Sample inputs and outputs

Note: Some of the output appear wrapped in the sample output below. User inputs are

shown in bold.

Base case #1:

title=M%61tr%69x&genre=&startYear=&endYear=

Content-Type: text/html

<!DOCTYPE html>

<html>

<head>

<link type='text/css' rel='stylesheet' href='movie.css'/>

</head>

<body>

<div class='movie'>

<p><span class='title'>Matrix, The</span> (1999). Genres: Action|SciFi|Thriller</p>

<p>Rating: 4.19245 (from 278 ratings). Link to IMDB: <a

href='https://www.imdb.com/title/tt0133093' target='other'>133093</a></p>

</div>

<div class='movie'>

<p><span class='title'>Matrix Reloaded, The</span> (2003). Genres:

Action|Adventure|Sci-Fi|Thriller|IMAX</p>

<p>Rating: 3.35417 (from 96 ratings). Link to IMDB: <a

href='https://www.imdb.com/title/tt0234215' target='other'>234215</a></p>

</div>

<div class='movie'>

<p><span class='title'>Matrix Revolutions, The</span> (2003). Genres:

Action|Adventure|Sci-Fi|Thriller|IMAX</p>

<p>Rating: 3.1519 (from 79 ratings). Link to IMDB: <a

href='https://www.imdb.com/title/tt0242653' target='other'>242653</a></p>

</div>

<div class='movie'>

<p><span class='title'>Animatrix, The</span> (2003). Genres:

Action|Animation|Drama|Sci-Fi</p>

<p>Rating: 3.7 (from 20 ratings). Link to IMDB: <a

href='https://www.imdb.com/title/tt0328832' target='other'>328832</a></p>

</div>

</body>

</html>

Extra functionality #1 Test #1:

title=&genre=C%2B%2B&startYear=&endYear=

Content-Type: text/html

<!DOCTYPE html>

<html>

<head>

<link type='text/css' rel='stylesheet' href='movie.css'/>

</head>

<body>

<div class='movie'>

<p><span class='title'>Adventures of RAObot</span> (2019). Genres:

Education|C++|Programming</p>

<p>Rating: 5 (from 0 ratings). Link to IMDB: <a

href='https://www.imdb.com/title/tt0001000' target='other'>1000</a></p>

</div>

</body>

</html>

Due before: 11:59 PM (before Midnight) on Wed April 10 2019

Page 5 of 6

Extra functionality #1 Test #2:

title=M%61tr%69x&genre=An%69m&startYear=&endYear=

<!DOCTYPE html>

<html>

<head>

<link type='text/css' rel='stylesheet' href='movie.css'/>

</head>

<body>

<div class='movie'>

<p><span class='title'>Animatrix, The</span> (2003). Genres:

Action|Animation|Drama|Sci-Fi</p>

<p>Rating: 3.7 (from 20 ratings). Link to IMDB: <a

href='https://www.imdb.com/title/tt0328832' target='other'>328832</a></p>

</div>

</body>

</html>

Extra functionality #2 Test #1:

title=&genre=&startYear=%32%30%31%39&endYear=

Content-Type: text/html

<!DOCTYPE html>

<html>

<head>

<link type='text/css' rel='stylesheet' href='movie.css'/>

</head>

<body>

<div class='movie'>

<p><span class='title'>Adventures of RAObot</span> (2019). Genres:

Education|C++|Programming</p>

<p>Rating: 5 (from 0 ratings). Link to IMDB: <a

href='https://www.imdb.com/title/tt0001000' target='other'>1000</a></p>

</div>

</body>

</html>

Extra functionality #2 Test #2:

title=&genre=&startYear=&endYear=1902

Content-Type: text/html

<!DOCTYPE html>

<html>

<head>

<link type='text/css' rel='stylesheet' href='movie.css'/>

</head>

<body>

<div class='movie'>

<p><span class='title'>Trip to the Moon, A (Voyage dans la lune, Le)</span>

(1902). Genres: Action|Adventure|Fantasy|Sci-Fi</p>

<p>Rating: 3.5 (from 5 ratings). Link to IMDB: <a

href='https://www.imdb.com/title/tt0000417' target='other'>417</a></p>

</div>

</body>

</html>

Due before: 11:59 PM (before Midnight) on Wed April 10 2019

Page 6 of 6

Extra functionality #2 Test #3:

title=M%61tr%69x&genre=&startYear=&endYear=%32%30%300

Content-Type: text/html

<!DOCTYPE html>

<html>

<head>

<link type='text/css' rel='stylesheet' href='movie.css'/>

</head>

<body>

<div class='movie'>

<p><span class='title'>Matrix, The</span> (1999). Genres: Action|SciFi|Thriller</p>

<p>Rating: 4.19245 (from 278 ratings). Link to IMDB: <a

href='https://www.imdb.com/title/tt0133093' target='other'>133093</a></p>

</div>

</body>

</html>

Extra functionality #2 Test #4:

title=Toy&genre=Anim&startYear=1995&endYear=1999

Content-Type: text/html

<!DOCTYPE html>

<html>

<head>

<link type='text/css' rel='stylesheet' href='movie.css'/>

</head>

<body>

<div class='movie'>

<p><span class='title'>Toy Story</span> (1995). Genres:

Adventure|Animation|Children|Comedy|Fantasy</p>

<p>Rating: 3.92093 (from 215 ratings). Link to IMDB: <a

href='https://www.imdb.com/title/tt0114709' target='other'>114709</a></p>

</div>

<div class='movie'>

<p><span class='title'>Toy Story 2</span> (1999). Genres:

Adventure|Animation|Children|Comedy|Fantasy</p>

<p>Rating: 3.86082 (from 97 ratings). Link to IMDB: <a

href='https://www.imdb.com/title/tt0120363' target='other'>120363</a></p>

</div>

</body>

</html>

Turn-in:

This homework assignment must be turned-in electronically via Canvas CODE plug-in.

Ensure you have tested operations of your program by setting up your website. Once

you have tested your implementation, upload the following 3 source files onto Canvas:

1. The Movie.h and Movie.cpp modified as part of this homework

2. The homework6.cpp C++ source file modified for this homework.

Upload all the necessary C++ source files to onto Canvas via the CODE plug-in. Do not

submit zip/7zip/tar/gzip files. Upload each file independently.


版权所有:留学生程序网 2020 All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。