CIS 102 Advanced Programming Concepts
The Java Programming Class in Walnut Creek by Symon Chang

Come to the Java course, and you will know what you missed in here. :-)

The Course Descriptions

CIS 102 ADVANCED PROGRAMMING CONCEPTS - 3 UNITS
Provides a continuation of CIS 101, emphasizing object- and event-oriented programming. While the course is based on the Java programming language, it is not primarily a computer language (Java) class. Rather, it is a class in basic programming principles applicable to a variety of languages and programming environments.

You will study the most up-to-date programming technologies including object-oriented programming, visual programming, and programming for the Internet. Topics include object-based programming, object-oriented programming, strings and characters, graphics, basic graphical user interface (GUI) components, multithreading, bit manipulation and introductory data structures.


Prerequisite


CIS 101 Fundamental Programming Concepts, or consent of the instructor. To take this class, you should be familiar with basic programming concepts and Java programming language. If you have any questions regarding the prerequisites for this course, please see the instructor as soon as possible!

Text Book


Java Software Solutions by: John Lewis & William Loftus, Addison Wesley, 1998 

This course will cover


  • In this course, students will learn the principles underlying object-oriented programming, and de-sign a large application with multiple GUIs using Java. Upon completion of this course, students will understand the advanced programming concepts and Java programming language. By suc-cessfully completing this course, student should be able to do the following:
  • See some applet examples that will be covered in this class, in addition to what we have in the textbook. 

    Course Format



    Instructor


    Instructor Symon Chang has taught many Java classes in US, and published many Java articles on computer magazines in Taiwan. 


    Homework Assignments


    Week 1


    NOTE:

    If you install JDK 1.2 on Windows, read this page first. The size of JDK 1.2 is 20 MB. It will take 2+ hours to download under slow dial-up link.

    If you are using your home machine, follow the instructions for that compiler/interpreter. You will need to create a text file called Test.java and put these contents in it:

    class Test {
       public static void main (String []args) {
           System.out.println("Testing the Emergency Broadcast " +
                              "Program ");
       }
    }   
    
    
    Open a DOS window, and make sure you set the path:
    SET PATH=c:\jdk1.1.7\bin;%path%
    
    
    Where the c:\jdk1.1.7 is the directory that you install your JDK under.

    Then you should use the Java compiler (which is called javac) to compile it. Try this:

    javac Test.java 
    
    
    If everything is ok, you'll just get the prompt back. If there are errors in your code look at the error messages, fix the bugs, and try again. The result of a successful compilation is a .class file, so you should have Test.class in your directory now.

    To run the program, you need to invoke the Java interpreter on the resulting class (which is called Test). So use:

    java Test
    
    
    This should cause the program to run and print the message on the terminal. Note that you do not put the name of the file that has the compiled class in it, you put the name of the class.

    Note: If you want to know more in how to get start with Java, check here...

    Note: If you have problem with classpath, check here...


    Week 2


    To set-up your DOS windows for the Java class, you need to copy MS-DOS windows Icon from your desktop, and rename it to Java MS-DOS Window. Then, you need to change the properties of the Java Window. This will look like this....

    The setjdk.bat file will look like this:

    doskey
    SET PATH=c:\jdk1.1.7\bin;%path%
    SET CLASSPATH=.;c:\jdk1.1.7

    Week 2


    Please visit the following web pages:

    1. Class inheritance
    2. File I/O -- Sample is posted to news group.
    3. Serialization

    Week 3


    We will have the first mid-term on 04/06/99. The mid-term will cover the following topics:

    1. String Tokenizer -- page 237 - 241
    2. Try-Catch-Finally --page 488 - 498
    3. File I/O -- Hand-out and URL at File I/O
    4. Serialization -- Hand-out and URL at Object Persistence
    5. Vector -- page 232 - 236 and hand-out
      1. Size of the Vector
      2. Add an object element into Vector
      3. Get element from a Vector
      4. Remove an object from a Vector
      5. Change the content of an object in a Vector
    6. Search an object from a Vector -- page 222 - 224, and page 473 - 474

    Sample Employee.txt can be downloaded from here.


    Week 4


    AWT Programs

    We will start to do same simple AWT Applets like this:

    See EmployeeField.java for how to do it.

    Frequently Asked Questions

    1. Q: What am I missing?
       
      
      *********** OUTPUT *************
      C:\My Documents\java1\CIS102>java ClientVector
      
      Write vector to file Client.Vector.data
      Error on writing vector to Client.Vector.data
      java.io.NotSerializableException: Client
              at java.io.ObjectOutputStream.outputObject(Compiled Code)
              at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:248)
              at java.io.ObjectOutputStream.outputArray(Compiled Code)
              at java.io.ObjectOutputStream.checkSubstitutableSpecialClasses(ObjectOutputStream.java:340)
              at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:244)
              at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:369)
              at java.io.ObjectOutputStream.outputObject(Compiled Code)
              at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:248)
              at ClientVector.writeAndClose(ClientVector.java:52)
              at ClientVector.main(ClientVector.java:200)
      
      A: You need to implements java.io.Serializable on your Client class.

    2. Q: When I want to open a file, but the file is missing, How to catch this kind of error? A: Use try and catch on the file open command.

      Example:

      	
            String fName = "missing.txt";
      
      
            try {
                   /* Open FIle */ 
                     fileInput = new FileInputStream(fName);
              } catch (Exception e)  {
                      System.err.println("Unable to open " + fName);
      		return;
              } 
      
      

    Week 5 to 6


    EmployeeApp Program

    The EmployeeApp now is using Layout Manger. The class will like this:

    See EmployeeApp.java for how to do it.

    Frequently Asked Questions

    1. Q: Is there a way of me changing the font?
      A: The way to change font in the paint method is:
         public void paint(Graphics g) {
      
            g.setFont(new Font("TimesRoman", Font.BOLD, 26));
            g.drawString(sTitle, 0, 40);
      
            g.setFont(new Font("TimesRoman", Font.PLAIN, 14));
            g.drawString("Symon Chang", 64, 60);
            g.drawString("e-mail: symonchang@earthlink.net", 21, 80);
      
            g.setFont(new Font("TimesRoman", Font.BOLD, 12));
            g.drawString("Press 'About' again to cancel", 39, 106);
         }
      
      

      Hit this button to see the output.

      See TestAbout.java for how to do it.

    2. Q: What am I missing in my ProjectApp.class? It was OK before. I am getting null pointer exception like this:
       
      
      *********** OUTPUT *************
      D:\cis102\Homework\Project8_hw5\project>java ProjectApp
      Reading objects from Project.Vector.data ...
      Exception occurred during event dispatching:
      java.lang.NullPointerException
              at ProjectApp.action(ProjectApp.java:108)
              at java.awt.Component.handleEvent(Compiled Code)
              at java.awt.Component.postEvent(Compiled Code)
              at java.awt.Component.postEvent(Compiled Code)
              at java.awt.Component.postEvent(Compiled Code)
              at java.awt.Component.postEvent(Compiled Code)
              at java.awt.Component.dispatchEventImpl(Compiled Code)
              at java.awt.EventDispatchThread.run(Compiled Code)
      
      
      *********** PROGRAM *************
      
         public boolean action(Event evt, Object obj) {
            int id = 0; 
            String n;
            String desp;
            String c;
      	  
            if (evt.target == btnAdd) {   
                  n = txtProjName.getText().trim();
       	    if (n.length() < 1) {
      		showStatus("Error: Invalid Project Name");
      		return true;        
      	    }
                  a = v.getProjectByName(n);
      	    if ( null != a) {                 
      		showStatus("Error: " + n + " already exist");
                      return true;        
      	    }
      	 
      	    desp = txtProjDesp.getText().trim();
                  if (desp.length() < 1) {
      		showStatus("Error: Invalid Description");
      		return true;
                  }			
                  c = txtClientName.getText().trim();
                  if (c.length() < 1) {
                       showStatus("Error: Invalid Clinet Name");
                       return true;
                  }
                  c_exist = vc.getClientByName(c);  // This is line 108 
                  if (null == c_exist) {
                       showStatus("Error: Client " + c + " does not exist");
                       return true;
                  }	
      					
                  showStatus("Adding new Project Object");
                  id = v.getTotalProject() + 1;
                  a = new Project(c_exist, id, n, desp);
                  v.add(a);
                  can.repaint();
           }
      	  
           if (evt.target == btnSave) {
                  v.writeAndClose();
            }
            return true;
         }
      
      
      
      A: Your need to create the ClientVector object, before you use it. In your init() method, just add one more line:
      
            vc = new ClientVector();
      
      


    Week 7


    TipApplet Program

    TipApplet will show the Frame of Tips Menu, which is using Menu and MenuItem in AWT.

    Hit this to see the Tips Main Menu.


    Week 8


    EmployeeLocator Program

    EmployeeLocator.java will show how to get next Employee object.

    See Employee Locator Information for more information.


    Employee Manager Program

    EmployeeManager.java will show how to update and delete the Employee object.

    See EmployeeManager.java for how to do it.


    EmployeeID Program

    EmployeeID.java will show how to get the Employee object by EmployeeID.

    See EmployeeID.java for how to do it.


    DateTest Program

    DateTest.java will show how to get the Date object from GUI. It gets mm/dd/yy from GUI, and display the Date object.

    See DateTest.java for how to do it.


    Week 9


    Tips for TIPS Project

    See Tips for some tips.


    Other Notes


    How to create your own Web pages


    Important Java Links



    Students' Web Page



    Back to Home | Previous Page | Next Page | Any Page ]
    Symon Chang Symon & Associates, CA. U.S.A symonchang@earthlink.net

     

     

    Last modified: 05-11-99