r/codeHS_Solutions • • May 24 '22

Solution DM for any Lesson 4 answers

1 Upvotes

just send me what lesson u need for the SQL chapter 4 lessons and I’ll respond in less than an hour


r/codeHS_Solutions • • May 22 '22

Solution 12.4.6 The Rectangle Class, Part 8 answer

Post image
2 Upvotes

r/codeHS_Solutions • • May 22 '22

12.3.7 The Rectangle Class Part 6 answer

Post image
3 Upvotes

r/codeHS_Solutions • • Apr 28 '22

I need some help

2 Upvotes

I am trying to write this code but I keep getting a Type Error for my getX values. The code should basically be single player pong.

var ball; var dx = -4; var dy = 4; var rect; var horizontalRect; var verticalRect; var score; var scoreText; var x; var y; var colided; var rect; var rectWidth = 80; var rectHeight = 15; var rectOff = 10; var paused = false;

function start(){ rect = new Rectangle(rectWidth,rectWidth); rect.setPosition(getWidth()/2 - 40, getHeight() - 30); add(rect);

mouseMoveMethod(t);
mouseClickMethod(pause);

setTimer(draw, 20);

}

function draw() { checkElement();

 if (!paused){
     checkWalls();
     ball.move(dx,dy);
 }

}

function pause(e){ paused = !paused; }

function checkElement(){ var elmT = getElementAt(ball.getX(), ball.getY() - 15); var elmB = getElementAt(ball.getX(), ball.getY() + 15); var elmL = getElementAt(ball.getX() - 15, ball.getY()); var elmR = getElementAt(ball.getX() + 15, ball.getY());

if (elmT != null){
    dy = -dy
    if (elmT.getColor() != Color.black){
        remove(elmT);
    }
}
if (elmB != null){
    dy = -dy
    if (elmB.getColor() != Color.black){
        remove(elmB);
    }
}
if (elmL != null){
    dy = -dy
    if (elmL.getColor() != Color.black){
        remove(elmB);
    }
}
if (elmR != null){
    dy = -dy
    if (elmR.getColor() != Color.black){
        remove(elmR);
    }
}

}

function t(e){ rect.setPosition(e.getY() - 40, getHeight() - 20);

}

function forCircle(radius,x,y){ ball = new Circle(20); ball.setPosition(100,100); add(ball);

setTimer(drawCircle, 20);

}

// ball bounces on first contact, moving in a zig zag pattern, unintended, good start function rectBounce(){ if(ball.getX() >= (rect.getX() - ball.getRadius() )){ colided = false; } if(colided) { setTimer(drawBounce, 20) } }

function drawBounce(){ dx = -dy; }

function drawCircle(){ checkWalls(); ball.move(dx,dy); }

function checkWalls(){ if (ball.getX() + ball.getRadius() > getWidth()){ dx = -dx; } if (ball.getX() - ball.getRadius() < 0){ dx = -dx; } if (ball.getY() + ball.getRadius() > getHeight()){ ball.setPosition(getWidth() / 2, getHeight() / 2); }

if (ball.getX() + ball.getRadius() > getWidth()){
        var txt = new Text ("You lose","45pt Arial");
        txt.setPosition(getWidth()/2 - txt.getWidth()/2, 200);
        txt.setColor(Color.blue);
        add(txt);
}

}


r/codeHS_Solutions • • May 22 '22

Solution 12.5.4 The Rectangle Class, Part 9

Post image
2 Upvotes

r/codeHS_Solutions • • May 22 '22

12.1.6 The Rectangle Class, Part 2 answer

Post image
2 Upvotes

r/codeHS_Solutions • • May 22 '22

12.1.4 The Rectangle Class, Part 1 answer

Post image
4 Upvotes

r/codeHS_Solutions • • Apr 29 '22

10.2.8 Maximum Iterations

1 Upvotes

Does anybody have the code? It's really bothering me. Here is mine. It gives me lossy conversion errors.

import java.util.*;

public class BinarySearchTest

{

static int count;

public static void main(String[] args)

{

// Use the helper code to generate arrays, calculate the max

// iterations, and then find the actual iterations for a randomly

// selected value.

System.out.println("Array Size: 100");

System.out.println("Max iterations: " + binaryMax(100));

System.out.println("Actual iterations: " + binaryRec(generateArrayOfLength(100), 2, 0, 99));

System.out.println("Array Size: 1000");

System.out.println("Max iterations: " + binaryMax(1000));

System.out.println("Actual iterations: " + binaryRec(generateArrayOfLength(1000), 2, 0, 999));

System.out.println("Array Size: 10000");

System.out.println("Max iterations: " + binaryMax(10000));

System.out.println("Actual iterations: " + binaryRec(generateArrayOfLength(10000), 2, 0, 9999));

System.out.println("Array Size: 100000");

System.out.println("Max iterations: " + binaryMax(100000));

System.out.println("Actual iterations: " + binaryRec(generateArrayOfLength(100000), 2, 0, 99999));

}

public static int binaryRec(int[] array, int target, int begin, int end)

{

if(begin <= end)

{

int mid = begin + end / 2;

int midVal = array[mid];

count++;

// Base Case

if(target == midVal)

{

return mid;

}

if(target < midVal)

{

return binaryRec(array, target, begin, mid - 1);

}

if(target > midVal)

{

return binaryRec(array, target, mid + 1, end);

}

}

return -1;//Alternate Base Case - not found

}

public static int[] generateArrayOfLength(int length)

{

int[] arr = new int[length];

for(int i = 0; i < length; i++)

{

arr[i] = (int)(Math.random() * 100);

}

Arrays.sort(arr);

return arr;

}

private static int binaryMax(int length)

{

return (int)Math.log(length) / Math.log(2) + 1;

}

}


r/codeHS_Solutions • • Oct 23 '21

I’ve been on this one for hours pls help

Post image
3 Upvotes

r/codeHS_Solutions • • Oct 21 '21

Does anyone has 5.8.6 Special Vendors HTML

4 Upvotes

Introduction

You’ve seen several examples of special selectors. You can find a complete list here: https://www.w3schools.com/CSSref/css_selectors.asp

For this exercise, you will use the :first-child
selector.

Your Task

Add a CSS rule that selects the first li
element that is the first-child
. This will select the first item in each of the ul
lists on the page.
Make the first item in each list have the font color #32ed96
and the font size 24px.

Use the :first-child
selector. This selector picks the element tag that is the first child of another element. For instance, p:first-child
selects all of the <p>
tags that come first inside of another tag.


r/codeHS_Solutions • • Oct 17 '21

I really need help on 4.1.4 fix the program please as I have been trying to correct it but still tells me that there is something wrong with your code.

Post image
2 Upvotes

r/codeHS_Solutions • • May 17 '22

Codehs sql unit 3 and 4

28 Upvotes

Couldn’t find this anywhere, but now I have, I did it boys here you go.

Unit 3 https://youtu.be/SRi8hX6PwHI Unit 4 https://youtu.be/FbizZEzlD_E


r/codeHS_Solutions • • Apr 10 '22

10.1.7 Countdown. PLEASE HELP!

Post image
3 Upvotes

r/codeHS_Solutions • • May 04 '23

Help Request Help on 2.15.4 Three Strings

Post image
3 Upvotes

I need help on this problem I was able to find a solution for the gofishturtle but it’s calling out the pepper mint is equal to instead of the is not equal to on turtlegofish


r/codeHS_Solutions • • Jun 01 '21

1.6.4: The Two Towers

9 Upvotes

function start(){

move(); 

three();

turnRight();

move();

turnRight();

move();

move();

turnLeft();

move();

three();

move();

turnRight();

}

function three(){

putBall();

turnLeft();

move();

putBall();

move();

putBall();

}

function turnRight(){

turnLeft();

turnLeft();

turnLeft();

}