CS 280 Spring 2009                           Assignment 3 –Using Existing Classes – String, Random                        100 “Assignment” points

 

Assigned: 02/05/2009

Due: 02/12/2009 at the start of class

 

Pre-Lab (Do Before Lab):  Bring materials – a USB for a take home copy. Plan out your GUI, tasks, objects, and events needed for program. Plan out how you will solve the problem.

 

Main Assignment:

Imagine that you are writing a couple little bits of a program related to creating and administering user accounts for computers for an organization. We are a long way from being able to do the full job, so pay attention to what I’m asking for. You should create buttons to

1.  Creating a User Name and Password – The user name should be the first letter of the first name, followed by the first 5 letters of the last name, followed by a random two digit number between 10 and 99. The password should be 5 characters long, with each character randomly generated from among all letters (upper and lower case possible) and all digits 0-9. You probably will not figure out how to do this in a minute or less; you will have to think about it.  Think about it before Thursday’s lab!!

HINT: we have just talked about two library classes – Random and String; both are necessary (and we haven’t covered loops or branching, so those aren’t needed).

Also, it should make the Search capability (button, label, and text field, see below) visible.

2.  Clear – clears the inputs and outputs in the program

3.  Exit – Exits from the program

4.  Search – reports where a specified character (specified in a text field) is found in the current password (a String’s positions start with 0, so 0 means it is the first character in the password. -1 means the character was not found.  Adjust the results so the user is not confused.  If the user enters more than one character  in the text field (as shown below), the search can be done, but it will be searching for the characters  in that order adjacent to each other (which is unlikely to be found)..

 

Background Knowledge:

 

User Interface:

·         You’re just a beginning at setting up GUIs in NetBeans. Don’t worry too much about making the interface nice.  See my simple sample interface below – Don’t let that constrain your creativity. Use it to help understand what I see as inputs and outputs.

·         DO put your name on the GUI form either as a label or on the title bar

 

Miscellaneous Details:

o    If the user types capital letters in their name, the user ID should still be all lower case. There is a String method that will be useful for that.

o    The two digits at the end of the user ID should be able to be generated using one random number generation.

o    HINT: Password generation is best handled using a combination of Random and String methods

o    I purposely left the password short because we haven’t covered loops yet – so some code will be a bit of tedious repetition – so limited to just 5.

o    Make sure you read the documentation on the Random and Stirng methods so you know exactly how to use them.

 

Good Programming Practices:

·         MAKE SURE YOUR PROGRAM WORKS! (i.e. gets correct results).  It must provide all of the requested capabilities AND provide them in the expected way.  

·         Put YOUR NAME, e-mail address, and purpose of the program in comments at the beginning of the program (Netbeans should also automatically put in the date – which is also a very good practice). The purpose should be what the program is supposed to do, not the learning goals.

·         Name meaningfully all jbuttons, jtxtfields, jlabels, etc that will be referred to in code.

·         Indent to show any structure of the program (The IDE usually does this well if you don’t go back and change things – probably not much to worry about on this basic of a program)

·         You MUST include some comments that explain your program in order to get full credit; for this simple program put one comment for each button, and also explain “groups” of code for the create button.

 


Red Tape to Aid Grading:

·         Please set the name of the project to something other than the default name (JavaApplication1, …). 

·         Add  your name in a jlabel on the GUI form  and/or in the title bar.

 

Hand in:

 

Do your own assignments !!!!  Work that is copied or done with somebody (when not assigned to a group) will be punished. If programs are copied, both students will receive a zero for the assignment. If significant sections of programs are copied, points will be taken off. Changing small aspects of a copied program does not make it not a copy. Asking another for help on a step or two in a many-step assignment is acceptable; looking at another person’s program is temptation for cheating; handing in a near duplicate program is cheating

 

Sample Interface:

 

Preparing to Create an Account:

 

 


Account Created:

 

 

Preparing to Search Password:

 

 

Search Results as Dialog Box: