MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/codehs/comments/yhv01x/ight_so_i_need_help_with_596_concentric_circles/
r/codehs • u/[deleted] • Oct 31 '22
3 comments sorted by
3
If you figure it out pls let me know I need this
1
concentric circles :
function start(){
var x = getWidth() / 2;
var y = getHeight() / 2;
var RADIUS = 200;
var isRed = true; // Flag to track color alternation
while (RADIUS > 0) {
var circle = new Circle(RADIUS);
circle.setPosition(x, y);
circle.setColor(isRed ? Color.red : Color.black); // Set color based on flag
add(circle);
RADIUS -= 20;
isRed = !isRed; // Toggle flag for the next iteration
}
inventory :
var STARTING_ITEMS_IN_INVENTORY = 20;
var inventory = 20;
while (inventory > 0) {
println ("We have " + inventory + " items in inventory.");
var numBuy = readInt ("How many would you like to buy? ");
if (numBuy > inventory) {
println ("There is not enough in inventory for that purchase.");
println ("");
} else {
inventory = inventory - numBuy;
println ("Now we have " + inventory + " left.");
if (inventory == 0) {
println ("All out!");
3
u/ProfessionalStrike52 Nov 09 '22
If you figure it out pls let me know I need this
1
u/Charming-Chef2242 May 23 '24
concentric circles :
function start(){
var x = getWidth() / 2;
var y = getHeight() / 2;
var RADIUS = 200;
var isRed = true; // Flag to track color alternation
while (RADIUS > 0) {
var circle = new Circle(RADIUS);
circle.setPosition(x, y);
circle.setColor(isRed ? Color.red : Color.black); // Set color based on flag
add(circle);
RADIUS -= 20;
isRed = !isRed; // Toggle flag for the next iteration
}
}
1
u/Charming-Chef2242 May 23 '24
inventory :
var STARTING_ITEMS_IN_INVENTORY = 20;
function start(){
var inventory = 20;
while (inventory > 0) {
println ("We have " + inventory + " items in inventory.");
var numBuy = readInt ("How many would you like to buy? ");
if (numBuy > inventory) {
println ("There is not enough in inventory for that purchase.");
println ("");
} else {
inventory = inventory - numBuy;
println ("Now we have " + inventory + " left.");
println ("");
}
if (inventory == 0) {
println ("All out!");
}
}
}