Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-01-2008, 05:55 AM
Member
 
Join Date: Mar 2008
Posts: 1
vipergt89 is on a distinguished road
Calculating per hour statistics
Hey all,
Ive got a relatively simple question, and i understand why it doesnt work, but i was wondering if anyone had any suggestions or ideas on how to get it to work.

I am creating a discrete event simulator that takes customers, adds them to a wait line, and then to a teller if the teller is not busy.

I am supposed to return statistics as customers leave, such as wait time, completion time and **Average wait per hour** that means that for every hour, i need to calculate what the current average wait time is.

My code for average wait per hour:

public int averageWaitPerHour(){
double a = 0;
a = Clock.currentTime();
if(a % 60 == 0)
System.out.println("Running average: " + averageTime());
}


the error i am getting is that im referenceing a non static method from a static context, which i understand, i cannot assign variable a to Clock.currentTime().

I was just wondering if anyone had any suggestions on how i could return this with a non-static variable.

Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-01-2008, 06:46 AM
Zosden's Avatar
Senior Member
 
Join Date: Apr 2008
Posts: 386
Zosden is on a distinguished road
Lol I just finished this project. It took me 13 classes, which just happens to be my favorite number. This project was for my 102 class, and me and a friend worked on it together. It was a cool way to learn about queues.
__________________
My IP address is 127.0.0.1
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-01-2008, 08:25 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
referenceing a non static method from a static context
Code:
// Calling a static method. double a = Clock.currentTime(); // Calling an instance method. Clock clock = new Clock(); double a = clock.currentTime(); class Clock { double currentTime() { System.out.println("instance method"); return time; } static double currentTime() { System.out.println("static method/context"); return time; } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating trigonometric functions Java Tip java.lang 0 04-17-2008 12:56 AM
Calculating hyperbolic functions Java Tip java.lang 0 04-17-2008 12:55 AM
Calculating the DB connection time Java Tip Java Tips 0 01-20-2008 10:55 AM
Calculating sin of a double value Java Tip Java Tips 0 01-13-2008 10:13 PM
To display performance statistics as graphs using JSP, Spring and JBoss sheeba Enterprise JavaBeans 0 07-23-2007 11:10 AM


All times are GMT +3. The time now is 10:52 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org