mirror of
https://codeberg.org/info-bw-wiki/bluej-birdwatching.git
synced 2025-12-10 15:28:34 +01:00
Erster Commit, Aufgaben und Tests
This commit is contained in:
commit
2cff7468ce
5 changed files with 204 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
*.class
|
||||||
|
*.ctxt
|
||||||
48
Birdwatching.java
Normal file
48
Birdwatching.java
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
/**
|
||||||
|
* Die Übungen dieser Klasse sind stark an die Vorlage "bird-watcher"
|
||||||
|
* des Java-Tracks bei exercism.org angelehnt.
|
||||||
|
*
|
||||||
|
* https://github.com/exercism/java/tree/main/exercises/concept/bird-watcher
|
||||||
|
*
|
||||||
|
* Dieser Track steht unter einer MIT License:
|
||||||
|
* https://github.com/exercism/java/blob/main/LICENSE
|
||||||
|
*
|
||||||
|
* Anpassungen fürs Wiki
|
||||||
|
* @author Frank Schiebel
|
||||||
|
* @version Oktober 2024
|
||||||
|
*/
|
||||||
|
public class Birdwatching
|
||||||
|
{
|
||||||
|
private int[] birdsPerDay;
|
||||||
|
|
||||||
|
public Birdwatching()
|
||||||
|
{
|
||||||
|
this.birdsPerDay = getNumbersOfLast7Days();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getNumbersOfLast7Days() {
|
||||||
|
throw new UnsupportedOperationException("Lösche diese Zeile und implementiere die Lösung zur Aufgabe!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getToday() {
|
||||||
|
throw new UnsupportedOperationException("Lösche diese Zeile und implementiere die Lösung zur Aufgabe!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementTodaysCount() {
|
||||||
|
throw new UnsupportedOperationException("Lösche diese Zeile und implementiere die Lösung zur Aufgabe!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasDayWithoutBirds() {
|
||||||
|
throw new UnsupportedOperationException("Lösche diese Zeile und implementiere die Lösung zur Aufgabe!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCountForFirstDays(int numberOfDays) {
|
||||||
|
throw new UnsupportedOperationException("Lösche diese Zeile und implementiere die Lösung zur Aufgabe!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBusyDays() {
|
||||||
|
throw new UnsupportedOperationException("Lösche diese Zeile und implementiere die Lösung zur Aufgabe!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
100
BirdwatchingTest.java
Normal file
100
BirdwatchingTest.java
Normal file
|
|
@ -0,0 +1,100 @@
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Test-Klasse BirdwatchingTest.
|
||||||
|
*
|
||||||
|
* @author (Ihr Name)
|
||||||
|
* @version (eine Versionsnummer oder ein Datum)
|
||||||
|
*/
|
||||||
|
public class BirdwatchingTest
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Konstruktor fuer die Test-Klasse BirdwatchingTest
|
||||||
|
*/
|
||||||
|
public BirdwatchingTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setzt das Testgerüst fuer den Test.
|
||||||
|
*
|
||||||
|
* Wird vor jeder Testfall-Methode aufgerufen.
|
||||||
|
*/
|
||||||
|
@BeforeEach
|
||||||
|
public void setUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt das Testgerüst wieder frei.
|
||||||
|
*
|
||||||
|
* Wird nach jeder Testfall-Methode aufgerufen.
|
||||||
|
*/
|
||||||
|
@AfterEach
|
||||||
|
public void tearDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNumbersOfLast7Days()
|
||||||
|
{
|
||||||
|
Birdwatching bw = new Birdwatching();
|
||||||
|
int[] numbers = bw.getNumbersOfLast7Days();
|
||||||
|
assertEquals(numbers[0], 12);
|
||||||
|
assertEquals(numbers[1], 7);
|
||||||
|
assertEquals(numbers[2], 0);
|
||||||
|
assertEquals(numbers[3], 6);
|
||||||
|
assertEquals(numbers[4], 15);
|
||||||
|
assertEquals(numbers[5], 8);
|
||||||
|
assertEquals(numbers[6], 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testToday()
|
||||||
|
{
|
||||||
|
Birdwatching bw = new Birdwatching();
|
||||||
|
assertEquals(bw.getToday(), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIncrementTodaysCount()
|
||||||
|
{
|
||||||
|
Birdwatching bw = new Birdwatching();
|
||||||
|
bw.incrementTodaysCount();
|
||||||
|
assertEquals(bw.getToday(),8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCountForFirstDays()
|
||||||
|
{
|
||||||
|
Birdwatching bw = new Birdwatching();
|
||||||
|
int[] sums = {0, 12, 19, 19, 25, 40, 48, 55};
|
||||||
|
for(int i=0; i<7; i++ ) {
|
||||||
|
assertEquals(bw.getCountForFirstDays(i),sums[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetCountForMoreDaysThanTheArraySize() {
|
||||||
|
Birdwatching bw = new Birdwatching();
|
||||||
|
assertEquals(bw.getCountForFirstDays(10),55);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetBusyDays() {
|
||||||
|
Birdwatching bw = new Birdwatching();
|
||||||
|
assertEquals(bw.getBusyDays(),3);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
11
README.TXT
Normal file
11
README.TXT
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
PROJEKTBEZEICHNUNG: Birdwatching
|
||||||
|
PROJEKTZWECK: Einführung in Arrays, Wiki: https://info-bw.de/faecher:informatik:oberstufe:java:algorithmen:arrays:definition:start
|
||||||
|
VERSION oder DATUM: 09.10.2024
|
||||||
|
|
||||||
|
Die Übungen dieses Projekts sind stark an die Vorlage "bird-watcher"
|
||||||
|
des Java-Tracks bei exercism.org angelehnt.
|
||||||
|
|
||||||
|
https://github.com/exercism/java/tree/main/exercises/concept/bird-watcher
|
||||||
|
|
||||||
|
Dieser Track steht unter einer MIT License:
|
||||||
|
https://github.com/exercism/java/blob/main/LICENSE
|
||||||
43
package.bluej
Normal file
43
package.bluej
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
#BlueJ package file
|
||||||
|
dependency1.from=BirdwatchingTest
|
||||||
|
dependency1.to=Birdwatching
|
||||||
|
dependency1.type=UsesDependency
|
||||||
|
editor.fx.0.height=1036
|
||||||
|
editor.fx.0.width=1920
|
||||||
|
editor.fx.0.x=1914
|
||||||
|
editor.fx.0.y=0
|
||||||
|
objectbench.height=94
|
||||||
|
objectbench.width=776
|
||||||
|
package.divider.horizontal=0.6
|
||||||
|
package.divider.vertical=0.8007889546351085
|
||||||
|
package.editor.height=399
|
||||||
|
package.editor.width=654
|
||||||
|
package.editor.x=2428
|
||||||
|
package.editor.y=219
|
||||||
|
package.frame.height=600
|
||||||
|
package.frame.width=800
|
||||||
|
package.numDependencies=1
|
||||||
|
package.numTargets=2
|
||||||
|
package.showExtends=true
|
||||||
|
package.showUses=true
|
||||||
|
project.charset=UTF-8
|
||||||
|
readme.height=60
|
||||||
|
readme.name=@README
|
||||||
|
readme.width=49
|
||||||
|
readme.x=10
|
||||||
|
readme.y=10
|
||||||
|
target1.association=BirdwatchingTest
|
||||||
|
target1.height=70
|
||||||
|
target1.name=Birdwatching
|
||||||
|
target1.showInterface=false
|
||||||
|
target1.type=ClassTarget
|
||||||
|
target1.width=120
|
||||||
|
target1.x=60
|
||||||
|
target1.y=100
|
||||||
|
target2.height=70
|
||||||
|
target2.name=BirdwatchingTest
|
||||||
|
target2.showInterface=false
|
||||||
|
target2.type=UnitTestTargetJunit5
|
||||||
|
target2.width=120
|
||||||
|
target2.x=90
|
||||||
|
target2.y=70
|
||||||
Loading…
Add table
Add a link
Reference in a new issue