CIS283: Introduction to Application Programming with Java - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

CIS283: Introduction to Application Programming with Java

Description:

Earlier today I sent scores on all previous assignments ... The Music DB project. The Music database project is due next week (Aug 21st) ... The Music DB project ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 21
Provided by: jpC3
Category:

less

Transcript and Presenter's Notes

Title: CIS283: Introduction to Application Programming with Java


1
CIS283 Introduction to Application Programming
with Java
  • Jose perez-carballo
  • Summer 2008
  • Day 6

2
  • Announcements
  • Earlier today I sent scores on all previous
    assignments
  • Please let me know if you think you submitted
    some assignment that I didnt count

3
  • The Music DB project
  • The Music database project is due next week (Aug
    21st)
  • The specs are at http//www.calstatela.edu/facult
    y/jperezc/courses/CIS283/assignments/MusicDB/index
    .html
  • You should write code that complies with the
    specs above

4
  • The Music DB project
  • Please download http//www.calstatela.edu/faculty/
    jperezc/courses/CIS283/assignments/MusicDB/Test.cl
    ass
  • Into the same directory where you have all your
    MusicDB classes
  • Add the following code to your Driver.java file
  • Test tt new Test()
  • tt.runTests()

5
  • The Music DB project
  • Compile your project
  • javac java
  • Run the program
  • java Driver
  • Two numbers are printed similar to following
  • first code 9989336
  • second code 29968085
  • When you are done debugging please enter the two
    numbers in the web form that you will find in out
    website

6
  • Packages, Interfaces, and Other Class Features

7
  • Modifiers
  • modify the declarations
  • To define access public, protected and private
  • To create class methods and variables static
  • To finalize the implementations of classes,
    methods and variables final
  • To create abstract classes and methods abstract
  • To be used with threads synchronize and volatile

8
  • The modifier precedes the declaration
  • public class bycicle extends vehicle
  • private boolean online
  • static final double weeks 9.5
  • protected static final int MEANIN_OF_LIFE 42
  • public static void main(String args)

9
  • The return type is not a modifier
  • If there are several modifiers they can appear in
    any order (as lng as they precede everything
    else)
  • public static void main(String args)

10
  • Modifiers are optional
  • If you dont use any modifier Java assumes some
    reasonable deafults

11
  • Access modifiers
  • public vs private
  • Encapsulation

12
  • Access modifiers
  • The default is public
  • Class Person
  • String first
  • private String last
  • Class Driver
  • Public static void main(String args)
  • //test access modifiers of Persons fields

13
  • Neither private variables or methods are
    inherited by subclasses
  • All public methods and classes are inherited
  • Test this

14
  • Methods should be used to control access to
    private fields
  • These methods enforce encapsulation
  • In general it is considered to be good practice
    to make the class fields private and the methods
    used to control them public
  • They are called accessor methods
  • They may perform some tests
  • Example setZicode(int) and getZipcode()

15
  • A protected variable (or method) is inherited but
    not public

16
  • The static modifier
  • Used to create class variables and methods

17
  • final modifier
  • the final modifier is used with a variable to
    indicate its value will not change
  • It is a constant
  • The convention is to use only uppercase for such
    variables
  • public static PI 3.1416

18
  • packages
  • Like a library,
  • It is a collection of related classes
  • Used to organized large quantities of classes

19
  • ArrayList is in package java.util
  • You can use it as follows
  • java.util.ArrayListltStringgt db new
    java.util.ArrayListltStringgt()
  • Or you can write
  • import java.util.ArrayList
  • At the beginning of your file and then
  • ArrayListltStringgt db new ArrayListltStringgt()

20
  • x
  • x
Write a Comment
User Comments (0)
About PowerShow.com