• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help writing a code involving bar charts!

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey there..
Im studying Java programing at Uni... n have till now found it to be quite intersting..
I need some help writing code for last weeks lab session.
the details of what the lab involves is here... http://www.cs.uwa.edu.au/undergraduate/units/230.124/2001-1/labs/lab08.html
I have to create a class that rolls n returns the values thrown by a user specified no. of dice. I have made this class.
also there has to be a method in another class that plots the no.of times a particular number is thrown in form of Bar graphs.
how do I go about doing the bar graphs part?
Ill post you my code tommorrow from Uni.... plz. tell me where I am going wrong.

also I have created a method that draws a rectangle. thing is.... after specifying the x and y axis from where to start.... the rectangle is drawn downwards.
public void drawRectangle(int x, int y, int length, int width){
for (int i=0; i<width; i++){<br /> for (int j=length; j>0; j--){
c.drawLine(x+i, y+j, x+width, y+j);
}
}
}
where "c" is an instance variable pointing to "canvas" class and "drawLine" is a method in "canvas" class that draws a line give x1, y1, x2, y2.
thanx all
hope someone can help me out.
 
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a bar chart sort of 3d i can share it with you.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Val,
Can't you share it with the rest of us .
[This message has been edited by Cindy Glass (edited May 11, 2001).]
 
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The graphics coordinate system in Java is left to right top to bottom. This explains why your rectangle appears to be drawn upside down...

The first Java program I ever wrote was an Applet to draw diagrams from coordinates stored in a mainframe. I had to go through a lot of gyrations to reverse the polarity of the y coordinates, so believe me I feel your pain!

------------------
I'm a soldier in the NetScape Wars...
Joel
[This message has been edited by Joel Cochran (edited May 11, 2001).]
 
Fahed Ghazali
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanx mate.....
I would appreciate a copy of the bar chart code...
cheers..
Ill post my code for the lab soon.. could yall tell me wass wrong with it?
thanx
 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code is not elligant but it draws a simpple bar graph. I am posting it below. Also for some reason getX() and getY on IE does not work and generate Exceptions.
I used fixed data but it could be read from a file and fill an arrays.
<applet code = "Graph.class" codebase = "http://www.geocities.com/vdrantyev/"; width = 400 height = 300></applet>



[This message has been edited by Marilyn deQueiroz (edited May 13, 2001).]
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic