-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
DesignPatterns/IteratorEnComposite/ASDII_ChannelSurferStarter/src/domein/Channel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package domein; | ||
|
||
import java.util.Date; | ||
|
||
public class Channel { | ||
|
||
private final int numberChannel; | ||
|
||
public Channel(int number) { | ||
this.numberChannel = number; | ||
} | ||
|
||
public int getNumberChannel() { | ||
return numberChannel; | ||
} | ||
|
||
public Program getCurrentProgram() | ||
{ | ||
return new Program(new Date(), this); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
DesignPatterns/IteratorEnComposite/ASDII_ChannelSurferStarter/src/domein/Program.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package domein; | ||
|
||
import java.util.Date; | ||
|
||
public class Program { | ||
|
||
private final Channel channel; | ||
private final Date date; | ||
|
||
public Program(Date date, Channel channel) { | ||
this.date= date; | ||
this.channel = channel; | ||
} | ||
|
||
public int getNrChannel() { | ||
return channel.getNumberChannel(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
DesignPatterns/IteratorEnComposite/ASDII_ChannelSurferStarter/src/domein/Television.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package domein; | ||
|
||
public class Television { | ||
|
||
//TODO attributes | ||
|
||
|
||
public Television(int maxChannel) { | ||
//TODO | ||
} | ||
|
||
public Program getNextProgram() { | ||
//TODO | ||
return null; | ||
} | ||
|
||
public Program getPrevProgram() { | ||
//TODO | ||
return null; | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...osite/ASDII_ChannelSurferStarter/src/oefeningiteratorstarter/OefeningIteratorStarter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package oefeningiteratorstarter; | ||
|
||
import domein.Program; | ||
import domein.Television; | ||
|
||
public class OefeningIteratorStarter { | ||
|
||
private static final int MAX = 5; | ||
|
||
public static void main(String[] args) { | ||
Television television = new Television(MAX); | ||
System.out.printf("MAX channels %d%n", MAX); | ||
|
||
Program program = television.getNextProgram(); | ||
System.out.printf("next %d%n", program.getNrChannel()); | ||
program = television.getNextProgram(); | ||
System.out.printf("next %d%n", program.getNrChannel()); | ||
program = television.getPrevProgram(); | ||
System.out.printf("prev %d%n", program.getNrChannel()); | ||
program = television.getPrevProgram(); | ||
System.out.printf("prev %d%n", program.getNrChannel()); | ||
program = television.getPrevProgram(); | ||
System.out.printf("prev %d%n", program.getNrChannel()); | ||
program = television.getNextProgram(); | ||
System.out.printf("next %d%n", program.getNrChannel()); | ||
|
||
for (int i = 1; i < MAX; i++) { | ||
program = television.getNextProgram(); | ||
System.out.printf("next %d%n", program.getNrChannel()); | ||
} | ||
|
||
program = television.getPrevProgram(); | ||
System.out.printf("prev %d%n", program.getNrChannel()); | ||
program = television.getNextProgram(); | ||
System.out.printf("next %d%n", program.getNrChannel()); | ||
} | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
DesignPatterns/IteratorEnComposite/ASDII_ChannelSurferStarter/src/testen/TelevisionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package testen; | ||
|
||
import domein.Program; | ||
import domein.Television; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class TelevisionTest { | ||
|
||
private Television television; | ||
private final int MAX = 5; | ||
|
||
@BeforeEach | ||
public void before() { | ||
television = new Television(MAX); | ||
} | ||
|
||
@Test | ||
public void testChannels() { | ||
Program program = television.getNextProgram(); | ||
Assertions.assertEquals(1, program.getNrChannel()); | ||
program = television.getNextProgram(); | ||
Assertions.assertEquals(2, program.getNrChannel()); | ||
program = television.getPrevProgram(); | ||
Assertions.assertEquals(1, program.getNrChannel()); | ||
program = television.getPrevProgram(); | ||
Assertions.assertEquals(0, program.getNrChannel()); | ||
program = television.getPrevProgram(); | ||
Assertions.assertEquals(4, program.getNrChannel()); | ||
program = television.getNextProgram(); | ||
Assertions.assertEquals(0, program.getNrChannel()); | ||
for (int i = 1; i < MAX; i++) { | ||
program = television.getNextProgram(); | ||
Assertions.assertEquals(i, program.getNrChannel()); | ||
} | ||
program = television.getPrevProgram(); | ||
Assertions.assertEquals(3, program.getNrChannel()); | ||
program = television.getNextProgram(); | ||
Assertions.assertEquals(4, program.getNrChannel()); | ||
} | ||
@Test | ||
public void testVolgendeChannels() { | ||
int verwachteNrChannel = 1; | ||
for (int i = 0; i < 20; i++) { | ||
Program program = television.getNextProgram(); | ||
Assertions.assertEquals(verwachteNrChannel++, program.getNrChannel()); | ||
if (verwachteNrChannel == MAX) { | ||
verwachteNrChannel = 0; | ||
} | ||
} | ||
} | ||
@Test | ||
public void testPrevChannels() { | ||
int verwachteNrChannel = MAX - 1; | ||
for (int i = 0; i < 20; i++) { | ||
Program program = television.getPrevProgram(); | ||
Assertions.assertEquals(verwachteNrChannel--, program.getNrChannel()); | ||
if (verwachteNrChannel < 0) { | ||
verwachteNrChannel = MAX - 1; | ||
} | ||
} | ||
} | ||
} |
Binary file added
BIN
+1.06 MB
...s/IteratorEnComposite/ASDII_ChannelSurferStarter/vpproject/ASDII_ChannelSurferStarter.vpp
Binary file not shown.
Binary file added
BIN
+1.06 MB
...IteratorEnComposite/ASDII_ChannelSurferStarter/vpproject/ASDII_ChannelSurferStarter.vpp~1
Binary file not shown.
Binary file added
BIN
+49 KB
...s/IteratorEnComposite/ASDII_ChannelSurferStarter/vpproject/ASDII_ChannelSurferStarter.vux
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
...IteratorEnComposite/ASDII_ChannelSurferStarter/vpproject/diagrams/klassendiagram.vpclassd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#Visual Paradigm: DO NOT MODIFY THIS FILE! | ||
#Thu Jan 13 21:49:09 CET 2022 | ||
DiagramId=NBSfGlqGAqACAhKl | ||
Create=false | ||
ProjectId=OBcfGlqGAqACAgwO |