Question
/* This assignment as an SQL file is found here --> Homework 5 Functions.sqlDownload Homework 5 Functions.sql Consider the ancient game known as Rock, Paper,
/*
This assignment as an SQL file is found here --> Homework 5 Functions.sqlDownload Homework 5 Functions.sql
Consider the ancient game known as "Rock, Paper, Scissors" Its rules are simple: Rock (R) beats Scissors (S), Scissors beat Paper (p), and Paper beats Rock. Input to our game will come from a table named tblPlays with two fields of type CHAR(1) named "p1" and "p2": p1 | p2 funcWinner(p1, p2) ----+---- R | R T R | P 2 R | S 1 P | R 1 P | P T P | S 2 S | R 2 S | P 1 S | S T R | X # X | P # X | X # (12 rows) DO NOT ENTER THE WINNER DATA MANUALLY! You will create tblPlays as described and two functions: funcValidData( CHAR(1), CHAR(1) ) RETURNS BOOLEAN Returns TRUE if *both* parameters are 'R', 'P', or 'S'; otherwise returns FALSE. funcWinner( CHAR(1), CHAR(1) ) RETURNS CHAR(1). Returns '1' if the first parameter wins based on the rules above. Returns '2' if the second parameter wins. Returns 'T' if valid data and p1 = p2. Returns '#' on invalid data. Hint: funcWinner will call funcValidData.
Do you remember where I wrote: /* In general, we will *NEVER* use a loop to do what we can accomplish in SQL!!! */
SELECT ch, funcDigit(ch) AS digit FROM tblAllLetters; -- Significantly easier, huh? /* ... in the notes? Well, that's how you test it! (And you must test it.) Turn in an SQL file that drops & creates the table and inserts at least 12 rows as described. Turn in the code that creates the two functions *and* the test code. (The test code may be a single SQL select statement as in the example.)
*/
/* Grading criteria: Equally weighted at 50 points apiece. Based on 100%: Do they work? Do they meet specification? 40% Testing: 10% Format and naming conventions: 30% Overall style and efficiency. (Once you have validData, the winner *can* be resolved in four comparisons; however, we won't hold you to that.) 20% WARNING! AS THE CODE GETS MORE COMPLICATED, IT BECOMES EASY TO SPOT COLLUSION (COPYING). WHILE IT IS OK TO DISCUSS THE ALGORITHM, DO NOT SHARE YOUR ACTUAL CODE. */
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started