Have been working on this code for awhile and cant get it to work with Glut. Wondering if there is anything I can fix
#include <iostream>
#include "graph1.h"
using namespace std;
//Add Function Prototypes Here
int getNoPoints();
void getPoints(int x[], int y[], int no_points);
void drawPolyLine(int x[], int y[], int no_points);
int main()
{
//Variable Declaration/Initialization
int no_points = 0;
const int MAX_POINTS = 10;
int x[MAX_POINTS];
int y[MAX_POINTS];
//Display Graphics Window
displayGraphics();
//Prompt for the number of points
no_points = getNoPoints();
//Prompt for the data for the points
getPoints(x, y, no_points);
//Draw the polyline
drawPolyLine(x, y, no_points);
return 0;
}
//Function Stubs Follows
int getNoPoints()
{
//Declare local variables
int no_points = 0;
//Prompt for the number of points
cout << "Please Enter Number of Points ";
cin >> no_points;
//Return the number of points
return 0;
}
void getPoints(int x[], int y[], int no_points)
{
//Declare local variables
//Using a for-loop, prompt for the coordinates of
each point and store in arrays x and y
for (int i = 0; i < no_points; i++)
{
cout << "Please Enter
Cordinates for point" <<i+1;
cin >> x[i] >>
y[i];
}
}
void drawPolyLine(int x[], int y[], int no_points)
{
//Declare local variables
int circle;
int line;
int drawCircle(int radius, int center_x, int
center_y);
int drawLine(int x1, int y1, int x2, int y2, int
width);
//Use 1 for-loop for drawing the red circle on each
point
for (int p = 0; p < no_points; p++)
{
circle = drawCircle(5, x[p],
y[p]);
setColor(circle, 255, 0, 0);
}
//Use a second for-loop for drawing the lines -
remember there is always one less line than there are points!
for (int w = 0; w < no_points - 1; w++)
{
line = drawLine(x[w], y[w], x[w +
1], y[w + 1], 1); //std function to draw line
}
}
include header #include <graphics.h> and add the below code at second loop place
//Use a second for-loop for drawing the lines - remember there
is always one less line than there are points!
for (int i = 0; i < no_points-1; i++);
{
line(x[i],y[i],x[i+1],y[i+1]); //std function to draw line
}
Have been working on this code for awhile and cant get it to work with Glut....
4.a) 4.b> 4.c) C++ Programming Lab Exercise 09 Inheritance. Friend Functions, and Polymorphism (virtual functions) 4.a) Run the following code and observe the output. #include <iostream> #include <string> using namespace std; class Vehicle public: void print() { cout << "Print: I am a vehicle. \n"; } void display() { cout << "Display: I am a vehicle. \n"; } }; class Car: public Vehicle { public: void print() { cout << "Print: I am a car.\n"; } void display() { cout...
Create a FRACTAL Javafx program ; it should draw some kind of fractal image ( a pattern that repeats). .... you can start with code similar to this (but I DO NOT want you just doing this simple one.. do a more complex image) //call the following method from your start() method after you create an empty pane (start with your drawHouse code that you did last week): Pane pane = new Pane(); //create an empty pane drawCircle(pane, 50,50, 20); //draw...
Working with GLUT to create a connect 4 program. I'm struggling to figure out how to attach a circle token ( of either black or red depending on the player) to be attached to the mouse . So, the circle always moves with the mouse, and when the player clicks wherever, as long as its a good move, changes the other players color. I have no idea how to do this. I have a cursor function: void cursor(int x, int...
15. Define a class called Point. It has two private data members: x and y with int type; and three public member functions: a constructor, setPoint(int, int) and printPoint0. The constructor initializes the data members to 0. You need to use the operator?: to test whether x and y are positive. If not, assign them to 0. The function printPoint prints the message "(X, Y)" where X and Y are two integers. In the main program, first input the number...
A) Fix any errors to get the following program to run in your environment. B) Document each line of code with comments and describe any changes you had to make to the original code to get it to work. C) Write a summary of what your final version of the program does. You may also add white space or reorder the code to suit your own style as long as the intended function does not change. Program 3 #include...
I cant get the code to work. Any help would be appreciated. Instruction.java package simmac; public class Instruction { public static final int DW = 0x0000; public static final int ADD = 0x0001; public static final int SUB = 0x0002; public static final int LDA = 0x0003; public static final int LDI = 0x0004; public static final int STR = 0x0005; public static final int BRH = 0x0006; public static final int CBR = 0x0007; public static final int HLT...
Need done in C++ Can not get my code to properly display output. Instructions below. The code compiles but output is very off. Write a program that scores the following data about a soccer player in a structure: Player’s Name Player’s Number Points Scored by Player The program should keep an array of 12 of these structures. Each element is for a different player on a team. When the program runs, it should ask the user...
Write simplistic recursive Java code for Sierpinski I made a psuedo code tell me if anything wrong with it: // x - left edge, y - right edge, z - peak, num - number of times the program is supposed to run public void drawTriangle (int x, int y, int z, int num) maketriangle(x,y,z); //imaginary method to create triangle using coordinates. if (num == 0) { return; } else { int midxy = (y-x)/2; int midxz = (z-x)/2; int midyz...
OpenGL 2D i asked this question: Line graph using lines and point and i get this answer but when try to run i get error : [Error] 'drawLine' was not declared in this scope. [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings] . #include<math.h> #include"graphics.h const int width=800,height=600; int drawline(int movetoX, int movetoY, int drawX, int drawY, int textX, int textY, int colour, char *name) { moveto(movetoX,movetoY); setcolour(colour); lineto(drawX,drawY); outtextxy(textX,textY,name); } int main(){ double...
I need a program in c++ the same as below code but I want it to prompt the user to enter the number of elements after that I want it to ask the user to enter the array elements #include<algorithm> #include<stdio.h> #include<string.h> #include<iostream> using namespace std; int a[50]={2,5,4,3}; bool x[100]; int N=4;//number of elements int k=10;//target sum int sum;//current target sum int cmp(const void *a,const void *b) { return *(int *)b-*(int *)a; } void backtrace(int n) { if(sum>k) return...