Opgepast! Het lijkt erop dat je Dodona gebruikt binnen een andere webpagina waardoor mogelijk niet alles goed werkt. Laat dit weten aan je lesgever zodat hij het probleem kan oplossen door een instelling in de leeromgeving aan te passen. Ondertussen kan je op deze link klikken om Dodona te openen in een nieuw venster.
LogAnalyzer
Log in om je oplossingen te testen.
public class LogAnalyzer
{
// Where to calculate the hourly access counts.
private int[] hourCounts;
// Use a LogfileReader to access the data.
private LogfileReader reader;
/**
* Create an object to analyze hourly web accesses.
*/
public LogAnalyzer()
{
// Create the array object to hold the hourly
// access counts.
hourCounts = new int[24];
// Create the reader to obtain the data.
reader = new LogfileReader();
}
/**
* Analyze the hourly access data from the log file.
*/
public void analyzeHourlyData()
{
while(reader.hasNext()) {
LogEntry entry = reader.next();
int hour = entry.getHour();
hourCounts[hour] = hourCounts[hour] + 1;
//hourCounts[hour]++;
}
}
/**
* Print the hourly counts.
* These should have been set with a prior
* call to analyzeHourlyData.
*/
public void printHourlyCounts()
{
System.out.println("Hr: Count");
for(int hour = 0; hour < hourCounts.length; hour++) {
System.out.println(hour + ": " + hourCounts[hour]);
}
}
public void printHourlyCounts2()
{
System.out.println("Hr: Count");
for(int hourCount: hourCounts) {
System.out.println(hourCount);
}
}
public void printHourlyCounts3()
{
System.out.println("Hr: Count");
int hour = 0;
while(hour < hourCounts.length)
{
System.out.println(hour + ": " + hourCounts[hour]);
hour++;
}
}
/**
* Print the lines of data read by the LogfileReader
*/
public void printData()
{
reader.printData();
}
}
Je kunt zo vaak indienen als je wenst. Er wordt enkel rekening gehouden met je laatst ingediende oplossing.
Log in om je oplossingen te testen.