New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN: 9781305503922
Author: Patrick M. Carey
Publisher: Cengage Learning
bartleby

Concept explainers

Question
Book Icon
Chapter 14, Problem 7CP1

a)

Program Plan Intro

To create a moveBubble() method which moves the bubble across the bubble box, this method accepts two argumentsheight and width which represent height and width of the object and declaring variables, bubbletop equal to the value of the yPos property, bubblebottom equal to the sum of the yPos and radius properties, bubbleLeft equal to the value of the xPos property, and bubbleRight equal to the sum of the xPos and radius properties.

b)

Program Plan Intro

To declare a conditional if statement inside the moveBubble() method,for the bubbletop if it is less than zero or bubbleBottom is greater than the height argument, then the bubble has hit the top or bottom wall and if the condition is trure then changing the direction of the vertical velocity by letting this.yVelocity equal this.yVelocity.

c)

Program Plan Intro

To declare a conditional if statement inside the moveBubble() method, for the bubbleLeft is less than zero or bubbleRight is greater than the width argument, the bubble has hit the left or right wall and if the condition becomes true then changing the direction of the horizontal velocity by letting this.xVelocity equal this.xVelocity.

d)

Program Plan Intro

To declare new location to move the bubble by adding the value of the yVelocity property to yPos and adding the value of the xVelocity property to xPos inside the moveBubble() method.

Blurred answer

Chapter 14 Solutions

New Perspectives on HTML5, CSS3, and JavaScript

Ch. 14 - Prob. 11RACh. 14 - Prob. 12RACh. 14 - Prob. 13RACh. 14 - Prob. 14RACh. 14 - Prob. 15RACh. 14 - Prob. 1CP1Ch. 14 - Prob. 2CP1Ch. 14 - Prob. 3CP1Ch. 14 - Prob. 4CP1Ch. 14 - Prob. 5CP1Ch. 14 - Prob. 6CP1Ch. 14 - Prob. 7CP1Ch. 14 - Prob. 8CP1Ch. 14 - Prob. 9CP1Ch. 14 - Prob. 10CP1Ch. 14 - Prob. 11CP1Ch. 14 - Prob. 12CP1Ch. 14 - Prob. 13CP1Ch. 14 - Prob. 14CP1Ch. 14 - Prob. 15CP1Ch. 14 - Prob. 16CP1Ch. 14 - Prob. 17CP1Ch. 14 - Prob. 1CP2Ch. 14 - Prob. 2CP2Ch. 14 - Prob. 3CP2Ch. 14 - Prob. 4CP2Ch. 14 - Prob. 5CP2Ch. 14 - Prob. 6CP2Ch. 14 - Prob. 7CP2Ch. 14 - Prob. 8CP2Ch. 14 - Prob. 9CP2Ch. 14 - Prob. 10CP2Ch. 14 - Prob. 11CP2Ch. 14 - Prob. 12CP2Ch. 14 - Prob. 13CP2Ch. 14 - Prob. 14CP2Ch. 14 - Prob. 15CP2Ch. 14 - Prob. 16CP2Ch. 14 - Prob. 17CP2Ch. 14 - Prob. 18CP2Ch. 14 - Prob. 19CP2Ch. 14 - Prob. 20CP2Ch. 14 - Prob. 1CP3Ch. 14 - Prob. 2CP3Ch. 14 - Prob. 3CP3Ch. 14 - Prob. 4CP3Ch. 14 - Prob. 5CP3Ch. 14 - Prob. 6CP3Ch. 14 - Prob. 7CP3Ch. 14 - Prob. 8CP3Ch. 14 - Prob. 9CP3Ch. 14 - Prob. 10CP3Ch. 14 - Prob. 11CP3Ch. 14 - Prob. 12CP3Ch. 14 - Prob. 13CP3Ch. 14 - Prob. 14CP3Ch. 14 - Prob. 15CP3Ch. 14 - Prob. 16CP3Ch. 14 - Prob. 17CP3Ch. 14 - Prob. 18CP3Ch. 14 - Prob. 19CP3Ch. 14 - Prob. 20CP3Ch. 14 - Prob. 21CP3Ch. 14 - Prob. 22CP3Ch. 14 - Prob. 23CP3Ch. 14 - Prob. 24CP3Ch. 14 - Prob. 25CP3Ch. 14 - Prob. 26CP3Ch. 14 - Prob. 27CP3Ch. 14 - Prob. 28CP3Ch. 14 - Prob. 1CP4Ch. 14 - Prob. 2CP4Ch. 14 - Prob. 3CP4Ch. 14 - Prob. 4CP4Ch. 14 - Prob. 5CP4Ch. 14 - Prob. 6CP4Ch. 14 - Prob. 7CP4
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning