Академический Документы
Профессиональный Документы
Культура Документы
Course
Module
Laboratory
: 7. Loops (MonoDisplay)
Objectives
Software(s)
: Eclipse IDE
Instructions:
The Java programs created for this laboratory session can be stored in
C:\users\<your_userid>\EG1745-Lab on your laptop.
Page 1 of 19
SEG
Library
Method
Arguments
What it does
Usage Example
MonoDisplay.java
void openDisplay()
Nil
Pops up a Pixel window with 10 rows (0 to 9) and 20 columns (0 to 19)
public static void main(String[] args)
{
MonoDisplay.openDisplay();
}
Library
Method
Arguments
MonoDisplay.java
void setPixelON(int r, int c)
r : This represents the row number of the Pixel to turn on
c : This represents the column number of the Pixel to turn on
Set the pixel represented at position (r,c) to ORANGE
public static void main(String[] args)
{
MonoDisplay.openDisplay();
MonoDisplay.setPixelON(3,8);
}
What it does
Usage Example
Library
Method
Arguments
What it does
Usage Example
MonoDisplay.java
void setPixelOFF(int r, int c)
r : This represents the row number of the Pixel to turn off
c : This represents the column number of the Pixel to turn off
Set the pixel represented at position (r,c) to gray background
public static void main(String[] args)
{
MonoDisplay.openDisplay();
MonoDisplay.setPixelOFF(3,8);
}
Page 2 of 19
SEG
Library
Method
Arguments
Description
Usage Example
Library
Method
Arguments
Description
Usage Example
MonoDisplay.java
void pause(int t)
t
This represents the time (in milliseconds)
The screen will pause for duration of t milliseconds. This is to control
the speed of animation on the screen.
public static void main(String[] args)
{
MonoDisplay.openDisplay();
MonoDisplay.setPixelON(3,8);
MonoDisplay.pause(100); // pause the screen for 100ms
MonoDisplay.setPixelOFF(3,8);
}
MonoDisplay.java
void closeDisplay()
Nil
This will close the window.
public static void main(String[] args)
{
MonoDisplay.openDisplay();
MonoDisplay.pause(100);
MonoDisplay.closeDisplay();
}
Page 3 of 19
SEG
Task 1
1.1
Requirements
a)
1.2
Design
// How to ensure that the system only allows the user to enter between 0 and 9 for row
// How to ensure that the system only allows the user to enter between 0 and 19 for col
Page 4 of 19
SEG
1.3
Implementation
a)
b)
c)
1.4
Testing
Make sure you test at least the 4 corners of the screen, the center of the screen, and when the
user input is not within 0-9 for row and 0-19 for column.
Test Title
Case
Input
Expected Result
Page 5 of 19
SEG
Task 2 (Blinking Pixel)
2.1
Requirements
a)
2.2
Design
Page 6 of 19
SEG
2.3
Implementation
a)
b)
In the main method, call the blinkPixel method to perform the blinking.
2.4
Testing
Make sure you test at least the 4 corners of the screen, the center of the screen, and when the
user input is not within 0-9 for row and 0-19 for column.
Test Title
Case
Input
Expected Result
Page 7 of 19
SEG
Task 3 (Draw Vertical Line)
3.1
Requirements
a)
You are to draw a vertical column at a user-specified column number and height.
3.2
Design
Page 8 of 19
SEG
3.3
Implementation
a)
b)
In the main method, call the drawVertLine method to draw the Line.
3.4
Testing
Input
Expected Result
Page 9 of 19
SEG
Task 4 (Draw Horizontal Line)
4.1
Requirements
a)
You are to draw a horizontal line at a user-specified row number and length.
4.2
Design
Page 10 of 19
SEG
4.3
Implementation
a)
b)
In the main method, call the drawHorLine method to draw the Line.
4.4
Testing
Input
Expected Result
Page 11 of 19
SEG
Task 5 (Draw Horizontal Line at a given location)
5.1
Requirements
a)
b)
Do not show any portion of the line that extends beyond the right side of the Window.
5.2
Design
Page 12 of 19
SEG
5.3
Implementation
a)
b)
In the main method, call the drawHorLineAt method to draw the Line.
5.4
Testing
Input
Expected Result
Page 13 of 19
SEG
Task 6 (Draw Dotted Horizontal Line at a given location)
6.1
Requirements
a)
You are to draw a dotted horizontal line at a user-specified location and length.
b)
Do not show any portion of the line that extends beyond the right side of the Window.
6.2
Design
Page 14 of 19
SEG
6.3
Implementation
a)
b)
In the main method, call the drawDottedHorLineAt method to draw the Line.
6.4
Testing
Input
Expected Result
Page 15 of 19
SEG
Task 7 (Draw Rectangle Line at a given location)
7.1
Requirements
a)
b)
Do not show any portion of the rectangle that extends beyond the right side of the Window.
7.2
Design
Page 16 of 19
SEG
7.3
Implementation
a)
b)
In the main method, call the drawHorLineAt method repeated to draw the Rectangle.
7.4
Testing
Conduct at least 4 tests with various positions and length, and height.
Test Title
Case
Input
Expected Result
Page 17 of 19
SEG
Task 8 (Draw Fading Horizontal Line at a given location)
8.1
Requirements
a)
You are to draw a fading horizontal line at a user-specified location and length.
b)
Do not show any portion of the line that extends beyond the right side of the Window.
8.2
Design
Page 18 of 19
SEG
8.3
Implementation
a)
b)
In the main method, call the drawFadeHorLineAt method to draw the Line.
8.4
Testing
Input
Expected Result
Page 19 of 19