Unit #11: Programming Assignment#13
Total
Points: 10
Problem #1:
Modify
the solution to Example Program #1 such that, instead of simply randomly
drawing lines, the program randomly also draws rectangles and ovals.
Add the following to
“paintComponent” method:
·
Randomly
generate a number between 1 and 3:
a)
If the
number generated is 1, draw the line as described in Example Problem #1
b)
If the
number generated is 2, draw a rectangle
o
g.fillRect (int x, int y, int length, int
width) - derscribes
the x and y coordinates of the top left corner and the length and width of the
rectangle.
c)
If the
number generated is 3, draw an oval
o
g.fillOval (int x, int y, int length, int
width) – describes the x and y coordinates of the top left corner and the
length and width of the rectangle in which the oval is inscribed.
Problem #2:
In this program, you will implement a graphic user interface (GUI)
for a login screen. Your GUI will receive input for login and password from the
user and perform several checks on them as described below:
The graphic objects that make up the GUI are as below:
·
A JLabel with the text, “Login”
·
A JTextField for entering the login
·
A JLabel with the text, “Password”
·
A JTextField for entering the password
·
A JButton with the text, “Login”.
Once you enter the login and password and press the “Login”
button, your program should inform the user with several messages as specified
below:
·
If the user does not enter any input in the text field for login,
your program should display a window with the message, “No login was entered”.
·
If the user does not enter any input in the text field for
password, your program should display a window with the message, “No password
was entered”.
·
If the user enters a login name and password:
a.
Check if the login name contains at least one uppercase letter and
at least one number character (0-9).
b.
Check if the password contains at least one uppercase letter and
at least one number character (0-9).
c.
If the login name does not contain at least one uppercase letter
and at least one number character (0-9), your program should display a window
with the message, “Login must contain at least one letter from A-Z and 0-9
".
d.
If the password does not contain at least one uppercase letter and
at least one number character (0-9), your program should display a window with
the message, “Password must contain at least one letter from A-Z and 0-9
".
e.
If both login name and password contain at least one uppercase
letter and at least one number character (0-9), your program must check if the
login name has already been taken. If yes, your program should display a window
with the message, “Login name has been taken. Choose another name”. If no, your
program should display a window with the message, “Login and password are
created”.