Picture Draw (Roses) Using Polar Functions

Feb 23, 2015

I'm trying to make a code that will draw "roses" using polar functions. The code below is what I have, but when I run it nothing happens. What's missing?

package rose;
import edu.princeton.cs.StdDraw;
public class Rose {
public static void main(String [] args) {
int N = Integer.parseInt(args[0]);
StdDraw.setCanvasSize(512, 512);

[Code] .....

View Replies


ADVERTISEMENT

Guess Picture Game - How To Sort Picture Random Every Time

May 3, 2014

I will write guess the picture game. I didn't find for example 4*4 picture how to sort picture random everytime ?

For example , when game start random various are 2734856127348561 two times same picture...

View Replies View Related

Coordinate Conversion Project - Rectangular To Polar

Mar 6, 2014

Ok Im trying to create a code right now that will take a table of rectangular coordinates and convert them to Polar coordinates in the constructor. I will eventually calculate the total distance between all points in the calculateDistancePolar method but for now I am using it to test.

It doesnt like line 29 and 31 of the class Polar and I cannot figure out why.

public class Test {
public static void main(String[] args) {
double[][] coords = {{86.92, 2.47},{70.93, 27.81},{97.74, 34.36},{30.90, 35.14},{51.66, 31.70},{0.830, 21.77},{55.91, 66.62},{32.92, 75.23},{65.26, 72.53},{83.90, 4.710}};
System.out.println("X,Y Coordinates are:");
outputArray(coords);
Polar myTest = new Polar(coords);

[Code] .....

View Replies View Related

Applets :: Display A Picture By Clicking On Checkbox?

Jan 22, 2014

ItemListener: checkbox component

I want to display a picture by clicking on the checkbox.

Here is my code:

public class Dukes {
String action;
String friend;
public String getActionImage() {
return action;

[Code] .....

View Replies View Related

JSF :: Take Picture Using Webcam From Web Browser And Store It In Folder?

Sep 20, 2014

I am working in jsf application, in that one requirement is present. If we click "Take picture" button using webcam from web browser, image has to be captured and displayed in the screen. Finally by clicking save button picture has to be stored either in Database or in File Folder.

View Replies View Related

How To Make Picture Appear In Same Window As The Rest Of Drawings

Feb 12, 2014

I am trying to learn Java and while i was playing a bit with the basic knowledge that i have i encountered a problem. When i run the program, the lines and the picture appear in two separate windows when i compile the program. how can i make them appear in the same? The code is this:

public class Game

private int x;
private Picture pic;

[Code].....

View Replies View Related

Breakout Game - Adding Background Picture

Nov 16, 2014

I've been trying to post background picture for a long time in java. I've just finished writing breakout game and I want it to be more special and full of interesting things. I want to upload picture in java. I write

GImage image= new GImage("LEONARDO.JPG");
image.setSize(50,50)
add(image,200,400)

The size of the whole screen is 400,600.

View Replies View Related

Generating Picture - Black And White Sketch

Nov 19, 2014

I'm stuck with a problem. The code below generates a coloured image.

//Setting the size of the graphics window
final int WINDOW_DIMENSION = 200;
final int SIZE_FACTOR = 3;
EasyGraphics generate = new EasyGraphics(WINDOW_DIMENSION*SIZE_FACTOR,WINDOW_DIMENSION*SIZE_FACTOR);
 
//Constructing the arrays
char[][] firstArray = new char[WINDOW_DIMENSION][WINDOW_DIMENSION];
char[] secondArray = scan.toCharArray();
 
[Code] ...

What I would like to do is generate a picture which is mostly white but the colour boundaries of the original picture are in black. I tried using the code below but it doesn't produce what I wanted.

for (int a = 1; a < WINDOW_DIMENSION; a++) {
for (int b = 1; b < WINDOW_DIMENSION; b++) {
generate.setColor(0,0,0);
if(firstArray[a][b]!=firstArray[a-1][b] || firstArray[a][b]!=firstArray[a][b-1])
generate.setColor(255,255,255);
generate.plot(a,b);
}
}

View Replies View Related

Paint Window Moving Picture From Bottom To Top Diagonally

Sep 30, 2014

PaintWindow pw = new PaintWindow();
Random rand = new Random();
ImageIcon image = new ImageIcon("C:/Users/Ghostkilla/Desktop/gubbe.jpg");
setWidth(pw.getBackgroundWidth());
int height = pw.getBackgroundHeight();

[Code] ....

If you run this code it will move a picture from right to left and hit the left wall and then go to right again leaving the window (It stops there). I want to make so it hits left and then right wall continuously till someones close the window. So basically I am using a for loop to make it go left right all the time.

How to make so the picture moves from bottomleftcorner to toprightcorner diagonally without leaving the window.

View Replies View Related

Saving Picture From Byte Arrays Using Random Access File

Jul 12, 2014

I'm trying to save a picture from byte arrays using RandomAccessFile. The file appears but doesn't open (like its corrupted).

I'm using the bittorent protocol which gives a SHA-1 hash that I compare all the bytes with to verify the data. All the bytes pass the hash check and all the hashes are checked. So I'm pretty sure I'm getting all the bytes correctly.

Is there anything I can do that could tell what's going wrong?

public RUBTClient(final TorrentInfo2 tInfo, final String outFileName) {
...
this.outFileName = outFileName;
File destined = new File(outFileName);
try {
destined_file = new RandomAccessFile(destined, "rw");
destined_file.setLength(tInfo.file_length);
} catch (FileNotFoundException e1) {

[Code] .....

View Replies View Related

Read Picture And Print Out Number Of Blocks - Counting In Multidimensional Array

Dec 19, 2014

I have to write a program that will read a picture and then print out the number of blocks inside it.

I have to read the picture as a binary matrix of the size r - c (number of rows times number of columns). The blocks are groups of one or more adjacent elements with the value 1.

- Blocks are built exclusively of elements with value 1
- Each element with value 1 is a part of some block
- Adjacent elements with value 1 belong to the same molecule.

We only take into account the horizontal and vertical adjacency but not diagonal.

INPUT:

In the first line of the input we have the integers r and c, separated with one space.
Then we have the r lines, where each contains s 0's and 1's.
The numbers inside the individual lines are NOT separated by spaces.

The OUTPUT only print the number of blocks in the picture.

Example:

INPUT:
7 5
01000
00010
00000
10000
01000
00001
00100

OUTPUT:
6

THIS IS WHAT I CAME UP SO FAR:

import java.util.Scanner;
class Blocks{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
char ch[][];
int rowNum=sc.nextInt();
int columnNum=sc.nextInt();

[Code] ....

View Replies View Related

Functions Are Not Recognized

Oct 29, 2014

// set up the generator
CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
gen.addSigner(key, cert, CMSSignedDataGenerator.DIGEST_SHA224);
gen.addCertificatesAndCRLs(certsAndCRLs);
addsigner and addCertificatesAndCRLs are not found in netbeans.

Which version of Bouncy Castle and JDK version this supports?

View Replies View Related

Use Of Functions In Java

Feb 4, 2014

Write a function (or functions) that given a collection of files will produce a sum of integers from each line of each file. Each file can have any number of lines from 1 to N. Each line can contain only one integer and no other alphanumeric characters. All of the numbers from all of the files should be added to the final result. The result is just one number.

For either, what we are looking for is:

1. Clear separation of concerns
2. Well defined objects / interfaces
3. Application of good OO design principles to solve the problem
4. No code duplication
5. Test Driven Development
6. Well refactored code
7. Well tested code

View Replies View Related

Using Modulus To Alternate Between 2 Functions?

Feb 24, 2014

This code is for a game I'm making. I'm new to using modulus, and I've been looking all over the place for a tutorial that I can understand. No luck. :

What I'm trying to do is get the console to print "enemy hits player" as soon as enemyAttacksPlayer() is called.

After one second, "player hits enemy" should be printed, so it alternates between these two lines every second.

The issue is when I call enemyAttacksPlayer(), it takes a few seconds to print any lines, and this delay is kinda annoying.

public int time = 0;
 public void enemyAttacksPlayer() {
time++;
if (time % 120 == 60) {
System.out.println("enemy hits player");
} if (time % 120 == 0) {
System.out.println("player hits enemy");
}
}

I think I may be using % wrong.

View Replies View Related

Ambiguity In Overloaded Functions

Sep 22, 2014

I have an overloaded function 'f' as follows:

1. public void f(int i, long j){System.out.println("1");}
2. public void f(int...i){System.out.println("2");}
3. public void f(long l, long p){System.out.println("3");}
4. public void f(int j, int k){System.out.println("4");}

With the function call: f(1,2), the output is: 4.

My questions are the following:

a. Why is the compiler choosing #4 to execute and not the rest?
b. If I remove 4 and replace it with: 5. public void f(long j, int k){System.out.println("5");}, why does the compiler now give an error complaining of ambiguous function defintions when 'f' is called?

View Replies View Related

Using Same Parameters But Different Functions - Allowed Or Not?

Feb 12, 2014

I have made a class here that has two methods. As you guys can notice, in my two methods that I made, I have listed some arguments in there with parameters. My question is that the variables im using in first method, can they be identical on my second method? Is this ok to do?

public class StudentScore {
private int math;
private int science;
private int calc;
private int history;
private int pe;
 
[Code] .....

View Replies View Related

Basic Calculator Functions

Jul 2, 2014

my task is to add a few functions to an example calculator. I managed to add a divide button but I simply can't figure out how to add a working Pi and reciprocal function.

package newjavaproject;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class CalculateurNC extends Applet {

[code]....

View Replies View Related

Modify And Delete Functions

Apr 4, 2014

I am writing a program for my Java class and I have every function of the program working aside from the modify and delete button. I'm not sure how to make them work. The course material doesn't cover these functions at all.

Here is what I have so far.. which is practically nothing. If I need to post any other code I will, I just don't want to post more than needed because going through unnecessary code can waste time.

public void actionPerformed(ActionEvent e)
{
inventoryTotalField.setText(String.valueOf(genre[ArrayIndex].getInventoryTotal()));
//add button functions
if (e.getActionCommand() == "First")//if first button is clicked
{
ArrayIndex = 0;//set array index to the first element in the array
setFieldValues(); // display dvd info on the form

[Code] .....

View Replies View Related

Adding Functions To A Calculator

Dec 6, 2014

I've made a calculator that can add, subtract, multiply, and divide, but I still need a clear function and a square root one for it. I've tried going on the various calculator tutorials, but they don't work.

And here's my code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Calculator extends JPanel implements ActionListener
{
private JTextField display = new JTextField("0");
private String button = "789/456*123-0.+=";
private double result = 0;

[Code] .....

View Replies View Related

Plot Functions Using Abstract Methods

May 1, 2014

Assignment 13 – Plot functions using abstract methods (Plot functions using abstract methods) Write an abstract class that draws the diagram for a function. The class is defined as follows:

Java Code:

public abstract class AbstractDrawFunction extends JPanel {
/** Polygon to hold the points */
private Polygon p = new Polygon();
protected AbstractDrawFunction() {
drawFunction();

[code].....

For each function, create a class that extends the AbstractDrawFunction class and implement the f method. Figure below displays the drawing for the first three functions.how to make the jframe to work so that I displays the panel

Java Code:

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.LayoutManager;
import java.awt.Polygon;

[code]....

View Replies View Related

Plot Functions Using Abstract Methods

Apr 29, 2014

Assignment 13 – Plot functions using abstract methods

Write an abstract class that draws the diagram for a function. The class is defined as follows:

public abstract class AbstractDrawFunction extends JPanel {
/** Polygon to hold the points */
private Polygon p = new Polygon();
protected AbstractDrawFunction() {
drawFunction();

[Code] ...

Test the class with the following functions:

a.f(x) = x2;
b.f(x) = sin(x);
c.f(x) = cos(x);
d.f(x) = tan(x);
e.f(x) = cos(x) + 5sin(x);
f.f(x) = 5cos(x) + sin(x);
g.f(x) = log(x) + x2;

For each function, create a class that extends the AbstractDrawFunction class and implement the f method. Figure below displays the drawing for the first three functions.

View Replies View Related

Complex Math Functions With A Simple Web Page?

Feb 4, 2015

I am a 3rd year electrical engineer and I am working on a project on solar cell design in the developing world.For my project I am looking to create a very simple web page which can be used by people in the developing world to determine whether a photo voltaic system is suitable to their needs.

For this I want to have simple boxes where a user can input numbers and I used complex calculations to return values (a lot of trigonometric functions etc.), the values then should have the opportunity to be altered to the users digression. This will create a solar model.

For the load aspect of it I am looking to have drop down boxes for a number of components which the user can select and will have a numerical value in Watts which will sum to give total load on system. Ideally I would like to show this graphically in a pie chart showing how much energy each component is taking to give the option to remove.

I am also creating a statistical model which determines the likelihood of having no sunlight on a given day which looks at the solar output, battery capacity and load on the system and will return reliability of the system - this has not been completed but should be shortly.

Aim is to keep web page as simple as possible as unskilled computer users may want to use it.

View Replies View Related

Utility Functions For Square Matrices And Arrays

Nov 7, 2014

I am working on a number of utility functions for square matrices and arrays, and I keep having trouble with segmentation faults.

arrayUtils~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public class ArrayUtils {
//This function takes an array a, and returns the sum between indices
//i and j, where i is the lower index and j is the upper index. int size makes
//sure that the function doesn't go out of bounds.
public static int subSum(int[] a,int i, int j) {
int sum=0;

[Code] .....

View Replies View Related

Java Application That Functions As Lottery Game

Nov 23, 2014

I am writing a java application that will function as a lottery game, using arrays it prompts the user to enter 5 digits and matches them against the random lottery numbers generated.

import java.util.Random;
import java.util.Scanner;
public class App {
public static void main(String[] args) {
int NUM_DIGITS = 5;

[Code] ....

View Replies View Related

Rename To Functions And Lists Class File?

May 29, 2014

What are they the rename To functions and lists the class file?

View Replies View Related

Add Admin Functions With Login At Main Window

Dec 8, 2014

I want to add admin-functions with a login at the main-window.I added first a Key Listener and later a Key Binding to replace the Key Listener.Both worked if i don't changed the background.Now the Key Binding is on a transparent JPanel in front of all other objects. "createback ground (boolean vorwrts)" removed the JLabel wich is the behind all objects and add a new JLabel at this position. Here is the "main code" for this Problem:

//[...]import
public class Surface{
int dx,dy;JFrame O,Ox;
protected JButton Bx;
String[] Names;
Image [] Images=null,QImages=null;
JLabel background=null;JPanel Top;
protected boolean view=true,play=false;
 
[code]....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved