Jump to content

Repetition and Looping


Drewyboyo

Recommended Posts

Who needs loops wen u can just switch it up

int k= getWCExp(); //get ur wc exp cuz u need it

switch (k) {
    case 1: checkWCexp();break;
    case 2: checkWCexp();break;
    case 3: checkWCexp();break;
    case 4: checkWCexp();break;
    case 5: checkWCexp();break;
    case 6: checkWCexp();break;
    case 7: checkWCexp();break;
    case 8: checkWCexp();break;
    case 9: checkWCexp();break;
    case 10: checkWCexp();break;
    default: checkWCexp();break;
}

np

Edited by Hayase
  • Like 1
Link to comment
Share on other sites

import java.awt.*;
import java.applet.*;


public class Lab07Bst extends Applet
{
public void paint(Graphics g)
{
// Draw Grid
Expo.drawLine(g,250,0,250,650);
Expo.drawLine(g,500,0,500,650);
Expo.drawLine(g,750,0,750,650);
Expo.drawLine(g,0,325,1000,325);

int x1, y1, x2, y2, x, y, r;

// Draw Red Horizontal Lines
Expo.setColor(g,Expo.red);
x1 = 0;
y1 = 5;
x2 = 250;
y2 = 5;
for (int k = 1; k <= 32; k++)
{
Expo.drawLine(g,x1,y1,x2,y2);
y1 += 10;
y2 += 10;
}

int x3, y3, x4, y4;
// Draw Blue Vertical Lines
Expo.setColor(g,Expo.blue);
x3 = 255;
y3 = 0;
x4 = 255;
y4 = 325;
for (int t = 1; t <= 25; t++)
{
Expo.drawLine(g,x3,y3,x4,y4);
x3 += 10;
x4 += 10;
}


int x5, y5;
// Draw Black Diagonal Dots
Expo.setColor(g,Expo.black);
x5 = 510;
y5 = 280;
for (int u = 1; u <= 24; u++)
{
Expo.drawPoint(g,x5,y5);
x5 += 10;
y5 += -10;
}



int x6, y6, z6;
// Draw Green Concentric Circles
Expo.setColor(g,Expo.green);
x6 = 887;
y6 = 170;
z6 = 10;
for (int i = 1; i <= 12; i++)
{
Expo.drawCircle(g,x6,y6,z6);
z6 += 10;
}






// Draw Purple Concentric Ovals
int x7, y7, z7, h7;
Expo.setColor(g,Expo.purple);
x7 = 125;
y7 = 480;
z7 = 5;
h7 = 10;
for (int i = 1; i <= 20; i++)
{
Expo.drawOval(g,x7,y7,z7,h7);
z7 += 4;
h7 += 6;
}




// Draw Pink Concentric Arcs
int x8, y8, z8, h8, g8, i8;
Expo.setColor(g,Expo.pink);
x8 = 260;
y8 = 650;
z8 = 5;
h8 = 15;
i8 = 0;
g8 = 90;
for (int i2 = 1; i2 <= 19; i2++)
{
Expo.drawArc(g,x8,y8,z8,h8,i8,g8);
z8 += 12;
h8 += 16;
}






// Draw Brown Concentric Rectangles





// Draw Gold Sphere


Who needs loops wen u can just switch it up

int k= getWCExp(); //get ur wc exp cuz u need it

(switch k) {
    case 1: checkWCexp();break;
    case 2: checkWCexp();break;
    case 3: checkWCexp();break;
    case 4: checkWCexp();break;
    case 5: checkWCexp();break;
    case 6: checkWCexp();break;
    case 7: checkWCexp();break;
    case 8: checkWCexp();break;
    case 9: checkWCexp();break;
    case 10: checkWCexp();break;
    default: checkWCexp();break;
}

np

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...