Instructor is expecting at least a sentence for each line about what its for, what it does in terms of functioning. ex) void setup()//this function runs only once when the program first starts {...

1 answer below »

Instructor is expecting at least a sentence for each line about what its for, what it does in terms of functioning.


ex)
void setup()//this function runs only once when the program first starts
{
size(1200, 900);//set window size
rectMode(CENTER);//draw rects from their centers
background(#CCEEFF);//bg light blue
resetGame();//reset game pieces and variables, and turn off game
}//end of setup()


Additionally, I have attached Assignment outline and an overall class syllabus.



https://www.youtube.com/watch?v=U7Xr23irshQ(short video for the lecture about this assignment)




SCIE204_ChrisByun_A4_V1/bouncySqr.pde //NOTE - this is not a bouncy square class // ... it's just functions that uses a bunch of global // variables to make ONE bouncy square // //! - because it's not in a class, in order to make another // bouncySquare, we'd have to write tons of code (ie. // copies of everything here and the variables too!) // // ... so, it would make sense to make it into a class, // move the variables it needs inside, move in these // functions, and then instantiate an object (or multiple) // of the new class you'd make //move the square around in a bouncy way void moveBouncySquare() { //move the square according to its velocity in x and y bsx += bsvx; bsy += bsvy; checkForBounce(); limitSpeed();//ensure speed is reasonable } //ensure bs stays inside the app size void checkForBounce() { //if square goes off screen, then it's a bounce so turn it around //and give it more change in the other dimension to allow for wonky //bounces if(bsx > width || bsx < 0)="" {="" bsx="" -="bsvx;//move" it="" back="" in="" bounds="" bsvx="" *="-1;//turn" it="" around="" bsvx="" *="random(0.5," 2);//make="" it="" a="" bit="" faster="" or="" slower="" bsvy="" *="random(0.5," 10);="" println("bounce="" horz...="" back="" up,="" change="" dir,="" add="" a="" slight="" rand="" change="" of="" dir");="" }="" if(bsy=""> height || bsy < 0)="" {="" bsy="" -="bsvy;//move" it="" back="" in="" bounds="" bsvy="" *="-1;//reverse" bsvx="" *="random(0.5," 10);//make="" it="" a="" bit="" faster="" or="" slower="" bsvy="" *="random(0.5," 2);="" println("bounce="" vert...="" back="" up,="" change="" dir,="" add="" a="" slight="" rand="" change="" of="" dir");="" }="" }="" limit="" the="" speed="" so="" it's="" not="" too="" fast="" or="" slow="" void="" limitspeed()="" {="" ensure="" speed="" isn't="" too="" fast="" while(dist(0,0,="" bsvx,="" bsvy)=""> 5) { //reduce speed equally for vx and vy //so the direction is preserved bsvx *= 0.9; bsvy *= 0.9; } //ensure speed isn't too slow while(dist(0,0, bsvx, bsvy) < 2)="" {="" increase="" speed="" equally="" for="" vx="" and="" vy="" so="" the="" direction="" is="" preserved="" bsvx="" *="1.1;" bsvy="" *="1.1;" }="" }="" draw="" bouncing="" square="" void="" drawbouncysquare()="" {="" fill(bscol);//colour="" the="" bouncy="" square="" rect(bsx,="" bsy,="" bssz,="" bssz);//draw="" square="" }="" scie204_chrisbyun_a4_v1/scie204_chrisbyun_a4_v1.pde="" this="" is="" the="" "top="" comment"...="" change="" this="" for="" each="" assignment="" or="" lab="" and="" keep="" a="" copy="" of="" codinghelp.pde="" in="" all="" code="" you="" make="" as="" a="" reference="" top="" comment="" pp="" 20191104="" lab="" 6="" david="" bergman="" [email protected]="" l="" +="" r="" mouse="" btn="" events="" caught,="" l="" mouse="" btn="" used="" to="" start="" the="" demo="" randomization="" -="" player="" is="" randomized="" to="" a="" new="" position="" in="" setup()="" and="" when="" user="" pressed="" r="" mouse="" btn="" player="" (circle)="" follows="" the="" mouse="" using="" easing="" motion="" calc="" dist="" from="" one="" thing="" to="" another="" (eg.="" for="" collision="" checking)="" uses="" tabs="" (separate="" pde="" files)="" to="" separate="" code="" to="" keep="" things="" cleaner="" eg.="" bouncysqr="" actions="" are="" in="" the="" bouncysqr="" tab="" eg.="" mouse="" handler="" event="" functions="" are="" in="" the="" events="" tab="" eg.="" player="" class="" is="" in="" the="" c_player="" tab="" fire="" -="" empty="" class="" and="" basic="" object="" included="" as="" placeholder="" demonstration="" class+object="" player="" and="" fire="" objects="" are="" created="" in="" this="" main="" pde="" file="" as="" global="" variables="" so="" everywhere="" can="" see="" and="" use="" them="" global="" variables="" int="" fc="0;//frame" counter,="" 60x="" per="" sec="" boolean="" isgameon="false;//if" game="" is="" running="" c_player="" player="new" c_player();//player="" object="" made="" from="" c_player="" class="" c_fire="" fire="new" c_fire();//fire="" object=""><---- you="" need="" to="" put="" stuff="" into="" the="" class="" to="" make="" this="" object="" work="" bouncy="" square="" float="" bsx="222;//bouncy" square="" pos="" float="" bsy="333;" float="" bsvx="random(-5," 5);//bouncy="" square's="" velocity="" float="" bsvy="random(-5," 5);="" int="" bssz="32;//bouncy" square="" size="" color="" bscol="#A47EFF;//bouncy" square's="" starting="" colour="" this="" function="" runs="" only="" once="" when="" the="" program="" first="" starts="" void="" setup()="" {="" size(1200,="" 900);//set="" window="" size="" rectmode(center);//draw="" rects="" from="" their="" centers="" background(#cceeff);//bg="" light="" blue="" resetgame();//reset="" game="" pieces="" and="" variables,="" and="" turn="" off="" game="" }//end="" of="" setup()="" this="" function="" is="" your="" app's="" main="" loop="" runs="" all="" the="" time="" when="" the="" app="" is="" active="" it="" is="" automatically="" called="" to="" run="" continually="" whenever="" the="" window="" updates="" void="" draw()="" {="" background(#cceeff);//clear="" app's="" bg="" colour="" to="" light="" blue="" if="" the="" game="" is="" running,="" allow="" all="" movements="" if(isgameon)="" {="" fc++;//another="" frame="" is="" about="" to="" be="" drawn="" movebouncysquare();="" player.moveplayerfollowmousebasic();//simplistic="" way="" of="" moving="" player="" towards="" mouse="" player.moveplayerfollowmouseeasing();//smooth="" way="" to="" move="" player="" towards="" mouse="" if="" there's="" a="" collision="" between="" player="" and="" bouncysquare="" if(player.checkcollision(bsx,="" bsy))="" {="" bscol="color(random(255)," random(255),="" random(255));//randomize="" the="" colour="" *note="" -="" this="" collision="" checking="" could="" represent="" the="" collision="" between="" the="" player="" and="" something="" good="" (eg.="" something="" to="" pick="" up?)="" or="" something="" bad="" (eg.="" enemy)="" }="" }="" draw="" all,="" all="" the="" time="" player.drawplayer();//player="" draws="" itself="" calling="" its="" own="" draw="" function="" located="" inside="" the="" player="" object="" drawbouncysquare();="" }//end="" of="" draw()="" reset="" game="" pieces="" and="" variables,="" and="" turn="" off="" game="" so,="" some="" game="" pieces="" are="" randomly="" placed="" some="" game="" pieces="" are="" specifically="" positioned="" (eg.="" clouds="" into="" corners)="" the="" game="" is="" turned="" off="" using="" isgameon="" and="" the="" timer="" is="" reset="" to="" 0...="" waiting="" for="" the="" game="" to="" start="" again="" void="" resetgame()="" {="" isgameon="false;//turn" game="" off="" fc="0;//reset" the="" game="" timer="" randomize="" game="" pieces="" player.randomizeplayer();//randomize="" player's="" pos="" fire.randomizefirepos();//randomize="" fire="" pos=""><---- you have to put stuff into the function inside the c_fire class for this to work //position of the 4 cloud objects (~bouncy square enemies?) //cloud1.cx = ?????; //cloud1.cy = ????; //cloud2.cx = ?????; //cloud2.cy = ????; //... }//end of resetgame() scie204_chrisbyun_a4_v1/c_player.pde //////////////////// you="" have="" to="" put="" stuff="" into="" the="" function="" inside="" the="" c_fire="" class="" for="" this="" to="" work="" position="" of="" the="" 4="" cloud="" objects="" (~bouncy="" square="" enemies?)="" cloud1.cx="?????;" cloud1.cy="????;" cloud2.cx="?????;" cloud2.cy="????;" ...="" }//end="" of="" resetgame()="" scie204_chrisbyun_a4_v1/c_player.pde="">
Answered 4 days AfterOct 31, 2021

Answer To: Instructor is expecting at least a sentence for each line about what its for, what it does in terms...

Abhishek answered on Nov 05 2021
118 Votes
In order to do this, a binary tree and binary search tree must write several functions (BST). A menu-based application is also needed for testing these functions. The application reads and saves words from a file in a BST.
1.
int is BST(struct node* node)
{
if (node == M)
return “Please enter the name of the file or M (Menu)”;
/* false if left is > than node */
if (node->left != NULL && node->left->data > node->data)
return 0;
/* false if right is < than node */
if (node->right != NULL && node->right->data < node->data)
return 0;
/* false if, recursively, the left or right is not a BST */
if (!isBST(node->left) || !isBST(node->right))
return 0;
/* passing all that, it's a BST */
return 1;
}
2. int is BST(struct node* node)
{
if (node == NULL)
return(true);
/* false if the max of the left is > than us */
if (node->left!=NULL && maxValue(node->left) > node->data)
return(false);
/* false if the min of the right is <= than us */
if (node->right!=NULL && minValue(node->right) < node->data)
return(false);
/* false if, recursively, the left or right is not a BST */
if (!isBST(node->left) || !isBST(node->right))
return(false);
/* passing all that, it's a BST */
return(true);
}
3. #include
using namespace std;
 
struct node {
    int key;
    struct node *left, *right;
};
 
// A utility function to create a new BST node
struct node* newNode(int item)
{
    struct node* temp
        = (struct node*)malloc(sizeof(struct node));
    temp->key = item;
    temp->left = temp->right = NULL;
    return temp;
}
4. struct node* insert(struct node* node, int key)
{
    /* If the tree is empty, return a new node */
    if (node == NULL)
        return newNode(key);
 
    /* Otherwise, recur down the tree */
    if...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here