Results 1 to 3 of 3
Thread: Calculating per hour statistics
- 05-01-2008, 03:55 AM #1
Member
- Join Date
- Mar 2008
- Posts
- 1
- Rep Power
- 0
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
- 05-01-2008, 04:46 AM #2
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
- 05-01-2008, 06:25 AM #3
referenceing a non static method from a static context
Java 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; } }
Similar Threads
-
To display performance statistics as graphs using JSP, Spring and JBoss
By sheeba in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 03-11-2009, 05:36 PM -
Calculating trigonometric functions
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 10:56 PM -
Calculating hyperbolic functions
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 10:55 PM -
Calculating the DB connection time
By Java Tip in forum Java TipReplies: 0Last Post: 01-20-2008, 08:55 AM -
Calculating sin of a double value
By Java Tip in forum Java TipReplies: 0Last Post: 01-13-2008, 08:13 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks