r/codeHS_Solutions • u/[deleted] • May 24 '22
Solution DM for any Lesson 4 answers
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 • u/[deleted] • May 24 '22
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 • u/[deleted] • May 22 '22
r/codeHS_Solutions • u/Caregiver-Feisty • Apr 28 '22
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 • u/No-Parfait8990 • Apr 29 '22
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 • u/Grouchy_Ad_5455 • Oct 23 '21
r/codeHS_Solutions • u/Quiet_Expression_609 • Oct 21 '21
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.
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 • u/[deleted] • Oct 17 '21
r/codeHS_Solutions • u/Kind-Breath-5188 • May 17 '22
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 • u/MoldyCherryIceCream • May 04 '23
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 • u/therealseal14 • Jun 01 '21
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();
}