java report
TRANSCRIPT
MOUSE EVENT IN JAVA
________________________________________
Submitted To:
DAV College, Sector 10
Panjab University, Chandigarh
(2009-10)
Project Guidence by:
Mr. Anil Bhardwaj
Submitted by:
NEHA (466)
MANSIMRAN (498) AVIRRAL CHABBRA(481)
CERTIFICATE
1
It is certified that this project Mouse Event In Java is bonafide piece
of work carried out by the student studying M.Sc IT(Ist). They have
made their project Mouse Event In Java under the guidance of Mr.
Anil Bhardwaj..
Signature of project guide Signature of students
Mr. Anil Bhardwaj Neha Mansimran Aviral chabbra
ACKNOWLEDGEMENT
2
A formal statement of acknowledgement is hardly sufficient to
express our gratitude towards the personalities who have helped us
to undertake and carry out this project. We hereby convey our
thankfulness and obligation to all those who are providing us
valuable help, support and guidance to carry on this project.
First and foremost, we express our gratitude towards Mr
Anil bhardwaj(Lecturer- IT Dept.). His keen interest and
encouragement has been of immense help to us. he gave us unending
support and helped us in numerous ways from the stage when the
idea of the project was conceived. We are also thankful to Mr verma,
Mrs Jagat and others members of the IT Dept. for their valuable
time and suggestions regarding this project.
We thank the almighty god for blessing us with new
challenges in life and giving us enough strength to meet those
challenges. We owe everything to our parents who worked very hard
to provide us everything in life.
Finally we are indebted to our friends who showed
tolerance and maturity when we were preoccupied with composition
of the project cannot be expressed in words.
DECLARATION
3
We all the members of the group here by, declare that the project
report on “mouse event in java” is the result of the original work done
by us and to the best of our knowledge a similar work has not been
submitted earlier to the Panjab University or any other institution for
fulfillment of the requirements of course of study.
We have undergone all the necessary requirements and
formalities with the college that are necessary for the submission of this
project report.
This project report is submitted for partial fulfillment of
completion of 1st Sem of “Masters of Science (Information
Technology)” of Panjab University, Chandigarh.
Above statement by the candidates is true to the best of my knowledge.
(Mr.Anil Bhardwaj)
Dav College,sector 10
Panjab University, Chandigarh
INDEX
4
S.No Topic
1. Introduction
2. SDLC
3. Recognition of need
4. Feasibility Study
5. SRS
6. System Design
7. Input/Output Design
8. Implementation & Testing
9. Conclusion
10. Source code
10. Hardware & Software Req.
11. Bibliography
5
INTRODUCTION
This is the project prepared by us during the course of study in M.Sc.
(IT) 1st semester as prescribed in the syllabus of Panjab University.
The project name is “MOUSE EVENT IN JAVA”. The project is a
basic mouse events in java using swing.
This is a simple function that generates line, circle, rectangle. This
will work as you can pick or select a line, circle, rectangle any one of
them and click with mouse onto the given screen, this will draw
whatever you choose for draw.
6
THE SYSTEM DEVELOPMENT LIFE CYCLE (SDLC)
To understand system development, we need to recognize that a candidate system has
a life cycle, just like a living system or a new product. System analysis and design are
keyed to the system life cycle. The analysist must progress from one stage to another
methodically, answering key questions and achieving results in each stage.
The systems analyst gives a system development project meaning and direction. A
candidate system is approached after the analyst has a thorough understanding of user
needs and problems, has developed a viable solution to these problems, and then
communicates the solution through the installation of the candidate system.
In SDLC, various activities are isolated and sequenced for learning purposes, but in real
life they overlapped and highly interrelated.for example, when an analyst is evaluating
an existing operation, he/she is probably thinking about an alternative way that would
improve the system or wondering whether a given piece of hardware would be a critical
cost item to consider for a candidate system. Therefore, there can easily be overlap
during any phase of the cycle.
The various phases of SDLC are:
Recognition of need
Feasibility study
Analysis
Design
Implementation
Post-Implementation
Maintenance
7
The various phases of SDLC
RECOGNITIONOF
NEED
FEASIBILITY STUDY
ANALYSIS
DESIGN
IMPLEMENTA-TION
POST-IMPLEMENTA-
TION
MAIN-TENANCE
8
Reorganization and Need
LANGUAGE SELECTION
Introduction to Java
Java is an object-oriented programming language that was designed to meet the need of platform independent language. Java is used to create applications that can run on a single computer as well as a distributed network. Java is both a language and a technology used to develop stand alone and interest based applications.
With the increasing use of internet, Java has become a widely used programming language. Java software works everywhere, from the smallest devices,such as microwave ovens to supercomputers. Java programs are independent of the type of computer, operating sytem etc.
Types of Applications:
Applications that use CUI: Applications are executable programs that are controlled by the operating system. These applications have an access to system resources, such as file systems and can read and write to files on local computers.
Applications that use GUI: These applications are used in the windows environment. In GUI, you interact with the application in graphical mode.
Applets: Applets are small executable programs that run on a web page. These programs require a Java enabled browser. Such as Internet Explorer or Netscape Navigator. They have limited access to system resources.
Servlets: Sevlets are the programs that are used to extend the functionality of Web servers.
Characteristics:
The choice for having programming language that fulfills all these requirements is Java because it exhibits the following characteristics:
Simple: A Java programmer does not need to know the internal details of Java as to how memory is allocated to data because in Java, the programmer does not need to handle memory manipulation. Java is a simple language that can be learned easily.The syntax of Java statements is easy to understand.
9
Object-Oriented: ITt supports various features of an object-oriented language, such as abstraction, encapsulation, inheritance, and polymorphism. To implement the object-oriented language, the entire code of program must be written in within a class.
Compiled and Interpreted: The Java programs are first compiled and then interpreted.While compiling the compiler s/w checks all the errors and lists all the errors on the screen. The compiler converts the program into computer language.
The Java complier compiles the code with a bytecode that is understood by Java. When you compile a Java source code file, the Java compiler generates the bytecode, which is compiled Java program with .class extension. The Java interpreter can extcute Java code directly on any computer on which a JVM has been installed.
Portable: Portability refers to the ability of a program to run on any platform without changing the source code of the program. The programs developed on one computer can run on another computer, which might have a different platform.
Distributed: Java is used to develop applications that can be distributed among various computers on the network. Java is designed for distributed environment of the Internet because it supports the varios Internet protocols, such as TCP/IP.
Secure: Java does not allow the use of explict pointers, which are used to refer to the memory locations in a C++ program. All references to the memory are symbolic references, which means that the program cannot access the memory locations without proper authorization.
In Java, the compiled bytecode is strongly type checked. Any changes made in the bytecode are flagged as errors and the program doesnot execute. This ensures the security of the Java programs over the Internet.
10
Java’s Magic : Byte code
The key that allows Java to solve both the security and the portability problems just described is that the output of a Java compiler is not executable code. Rather, it is byte code. Bytecode is a highly optimized set of instructions designed to be executed by the Java Run time system, which is called the Java Virtual
Machine (JVM). That is, in its standard form, the JVM is an Interpreter for bytecode.
Only the JVM needs to be implemented for each environment and any Java program can run on any operating system. Programs are built either in notepad or in the Dos Editor and then executed in Dos prompt.
Compilation code :-
>javac file_name.java
Interpretation code :-
>java file_name
Java Keywords:-
Most of the keywords of Java are similar as that of C++ and others are like, try, catch, finally, package, synchronized, interface, etc.
Data Types:-
Data Type Range Byte 8 bits Short 2 bytes Integer 4 bytes Long 8 bytes Float 4 bytes Double 8 bytes Boolean True/False Character 2 bytes
11
OOP’s --- Object Oriented Programming
All in terms of Classes and Objects.
Main Concepts under OOPs are: Inheritance Polymorphism Packages Exception Handling
Java doesn’t implement pointers and therefore there is no such concept of Operator overloading.
What is an Object ?
An object is a software bundle of related variables and methods. Software objects are often used to model real-world objects you find in everyday life.
What is a Message ?
Software objects interact and communicate with each other using messages.
What is a Class ?
A class is a blueprint or prototype that defines the variables and the methods common to all objects of a certain kind.
What is Inheritance ?
A class inherits state and behavior from its super class. Inheritance provides a powerful and natural mechanism for organizing and structuring software programs.
What is an Interface ?
An interface is a contract in the form of a collection of method and constant declarations. When a class implements an interface, it promises to implement all of the methods declared in that interface.
How do these concepts translate into code ?
This section looks at a small applet, and shows you the code that creates objects, implements classes, sends messages, establishes a super class, and implements an interface.
12
Some Java Packages
Java.lang.* Java.awt.* Java.util.* Java.applet.* Java.net.* Java.io.* Java.sql Javax.swing, etc.
Java Categories Standalone Applications
• Console Based• Windows Based
Applets (works on browsers )
Operators in Java:-
Operator’s Type Operator’s Name
Arithmetic Operators + , - , * , / , % , ++ , -- , -= , += , *= , /= , %=
Bitwise Operators ~ , & , | , ^ , >> , >>> , << , &= , |= , ^= , >>= , >>>= , <<=
Relational Operators = = , != , > , < , >= , <=
Ternary Operator exp1? exp2 : exp3
13
ControlstatementsinJava:-
if statement , if-else , if-else-if , nested if switch case for loop while loop do-while loop , nested loops jump , break , continue , return
An example to illustrate a simple program of Java :-
Class A { int x ; void set (int a) { x = y ; } void show ( ) { System.out.println ("x : "+x); } }
class B { public static void main (String st[ ]) { A a = new A ( ) ; a.set (8) ; a.show ( ) ; } }
Comments This text file will be saved as B.java and then compiled with same name as ----- > javac B.java After compiling it , there will be three files ---- B , B.class , A.class .Then it will be executed as ----- > java BOutput will be ---- x: 8.“new" keyword is used here to allocate memory for an object, if we don't use this word, then it will be called as " reference variable " .Static, when members are declared as static, they can be accessed before an object is created without or with the reference of any object. These can be variables; methods, and blocks, static methods can’t access non-static variables, are shared in between the objects, and by default static variables is declared as final.
14
Access Specifiers :-
State Private Public Protected Default
Same Package
Yes
Yes
Yes
Yes
Same Package subclass
No
Yes
Yes
Yes
Same Package non-subclass
No
Yes
Yes
Yes
Different Package subclass
No
Yes
Yes
No
Different Package non-subclass
No
Yes
No
No
15
Constructors
A constructor initializes an object immediately upon creation. It has the same name as that of
class in which it resides and is syntactically similar to a method. Once defined, the constructor
is automatically called immediately after the object is created.
Parameterized Constructors Passing some arguments to the constructor makes call it as parameterized one.
Inheritance
Inheritance is one of the cornerstones of OOPs because it allows the creation of hierarchical classifications. Using inheritance, we can create general class traits common to a set of related items. This class can then be inherited by other, more specific classes, each adding those things that are unique to it. In the terminology of Java, a class that is inherited is known as super class. The class that does the inheritance is called a subclass. Therefore, subclass is a specialized version of super class.
To inherit a class, we simply incorporate the definition of one class into another by using the extends keyword.
Packages
Java provides the mechanism for partitioning the class name space into more manageable chunks. This mechanism is known as Package. The package is both a naming and a visibility control mechanism. We can define classes inside a package that are not accessible by the code outside that package. This allows our classes to have intimate knowledge of each other, but not expose it to the rest of the world.
This is the general form of package statement:
package pkg ;
pkg is the name of the package .
We can create hierarchy of packages:
package pk1[.pk2[.pk3] ;
We can also import one package into another package using import statement .
import pk1[.pk2].(classname|.*) ;
16
...
Conversions
implicit conversions up to larger integral typeexplicit conversions (casts) to smaller types and other numeric typesint x = (int) 24.7; // 24byte b = (byte) 300; // 44
Data “Wrappers”
A class for each primitive data type, e.g. Integer for intinstances “wrap around” a primitive value. Treat a primitive asan object.Use TYPEValue methods. Immutable provide conversion to/from other primitive data types and String
Variablesvars of primitive types contain valuesvars of class types contain references to objects .
Variable Declarationall declarations are definitions (no “extern”)char c;double x, y = 0, z;constants : final keyword. Can’t change once assigned a value.final int x = 5;
Blocks and scope
Variables are visible in scope they are declared innested blocks can see vars in enclosing scopevariables can be declared anywhere in block, available thereafterclass fields/data members are different (seen later) .
Member Access
“dot notation”dereference object variableaccess an object’s methods and data members/fields (unless access not permitted). Either a field access or a method call.can be applied directly to classes (will see later)result is field value or method return value .
Arrays
Array variables are references, not pointers to memory locations
17
array size is fixed once set .
Array Operations
member access : a[0] = 12;length : int x = a.length;copying arrays :
System.arraycopy (a, 0, b, 0);more useful routines in java.util.Arrays .
Array Initialization
Allocation : default initializedint [ ] a = new int [10];Aggregate initializationint [ ] a = {10, -24, 0, 3928, 1, 0, 0, 0, 0, 0};Anonymous arraysmyObj.foo (new int [ ] {9, 2});
Multidimensional Arrays
char [ ][ ] a = {{’a’,’b’,’c’},{’y’,’z’},{’1’,’2’,’3’,’4’}};int [ ][ ] board = new int [5][5];int [ ][ ][ ] chart = new int [12][ ][ ];
Strings
core Java class, defined in library as java.lang.Stringour first Java classsome special treatment syntactically .
Argument Passing
Java is pass-by-valueno explicit pass-by-reference, but remember that object variables are in fact referencesno pass-by-address .
Cleaning Up Unused Objects
Some object-oriented languages require that you keep track of all the objects you create and that you explicitly destroy them when they are no longer needed. Managing memory explicitly is tedious and error prone. The Java platform allows you to create as many objects as you want (limited, of course, by what your system can handle), and you don't have to worry about destroying them. The Java runtime environment deletes objects when it
18
determines that they are no longer being used. This process is called garbage collection.
An object is eligible for garbage collection when there are no more references to that object. References that are held in a variable are usually dropped when the variable goes out of scope. Or, you can explicitly drop an object reference by setting the variable to the special value null. Remember that a program can have multiple references to the same object; all references to an object must be dropped before the object is eligible for garbage collection.
The Garbage Collector
The Java runtime environment has a garbage collector that periodically frees the memory used by objects that are no longer referenced. The garbage collector does its job automatically, although, in some situations, you may want to run the garbage collection explicitly by calling the gc method in the System class. For instance, you might want to run the garbage collector after a section of code that creates a large amount of garbage or before a section of code that needs a lot of memory.
Finalization
Before an object gets garbage-collected, the garbage collector gives the object an opportunity to clean up after itself through a call to the object's finalize method. This process is known as finalization.
Most programmers don't have to worry about implementing the finalize method. In rare cases, however, a programmer might have to implement a finalize method to release resources, such as native peers, that aren't under the control of the garbage collector.
The finalize method is a member of the Object class, which is the top of the Java platform's class hierarchy and a superclass of all classes. A class can override the finalize method to perform any finalization necessary for objects of that type. If you override finalize, your implementation of the method should call super.finalize as the last thing it does. Overriding Methods talks more about how to override methods.
Creating and Using Objects
You create an object from a class by using the new operator and a constructor. The new operator returns a reference to the object that was created. You can assign the reference to a variable or use it directly.
A class controls access to its instance variables and methods by using the Java platform's access mechanism. Instance variables and methods that are accessible to code outside of the class that they are declared in can be referred to by using a qualified name. The qualified name of an instance variable looks like this:
19
objectReference.variableName
The qualified name of a method looks like this:
objectReference.methodName(argumentList)
or objectReference.methodName()
Characters and Strings
The Java platform contains three classes that you can use when working with character data:
• Character --A class whose instances can hold a single character value. This class also defines handy methods that can manipulate or inspect single-character data.
• String -- A class for working with immutable (unchanging) data composed of multiple characters.
• StringBuffer --A class for storing and manipulating mutable data composed of multiple characters.
Converting Objects to Strings
The toString Method
It's often convenient or necessary to convert an object to a String because you need to pass it to a method that accepts only String values. The reverseIt method used earlier in this lesson uses StringBuffer's toString method to convert the StringBuffer to a String object before returning the String.
Classes and Inheritance
In the lesson entitled Object-Oriented Programming Concepts you read about the concepts behind object-oriented programming. Now it's time to get to work and put those concepts to practical use in Java.
Creating Classes
This section provides a complete description of a larger class, Stack, and describes all of the components of a class that provide for the life cycle of an object created from it. It talks first about constructors, then about member variables and methods.
Managing Inheritance
This section tells you what you need to know to manage inheritance up and down from your classes. First, it describes generally what a subclass gets from its ancestors and specifically what every class gets from the Object class.
20
Second, it discusses how to control whether your class can be subclassed and whether its subclasses can override its methods.
Implementing Nested Classes
The Java programming language lets you define a class, called a nested class, within another class. Inner Classes are a special type of nested class.
Writing Abstract Classes and Methods
Sometimes, a class that you define represents an abstract concept and, as such, should not be instantiated. Take, for example, food in the real world. Have you ever seen an instance of food? No. What you see instead are instances of carrot, apple, and (our favorite) chocolate. Food represents the abstract concept of things that we all can eat. It doesn't make sense for an instance of food to exist.
Similarly in object-oriented programming, you may want to model an abstract concept without being able to create an instance of it. For example, the Number class in the java.lang package represents the abstract concept of numbers. It makes sense to model numbers in a program, but it doesn't make sense to create a generic number object. Instead, the Number class makes sense only as a superclass to classes like Integer and Float, both of which implement specific kinds of numbers. A class such as Number, which represents an abstract concept and should not be instantiated, is called an abstract class. An abstract class is a class that can only be subclassed-- it cannot be instantiated.
To declare that your class is an abstract class, use the keyword abstract before the class keyword in your class declaration:
abstract class Number { . . .}If you attempt to instantiate an abstract class, the compiler displays an error similar to the following and refuses to compile your program: AbstractTest.java:6: class AbstractTest is an abstract class.It can't be instantiated. new AbstractTest(); ^1 error
Abstract Methods
An abstract class may contain abstract methods, that is, methods with no implementation. In this way, an abstract class can define a complete programming interface, thereby providing its subclasses with the method declarations for all of the methods necessary to implement that programming interface. However, the abstract class can leave some or all of the implementation details of those methods up to its subclasses.
21
Let's look at an example of when you might want to create an abstract class with an abstract method in it. In an object-oriented drawing application, you can draw circles, rectangles, lines, Bezier curves, and so on. Each of these graphic objects share certain states (position, bounding box) and behavior (move, resize, draw). You can take advantage of these similarities and declare them all to inherit from the same parent object--GraphicObject.
However, the graphic objects are also substantially different in many ways: drawing a circle is quite different from drawing a rectangle. The graphics objects cannot share these types of states or behavior. On the other hand, all GraphicObjects must know how to draw themselves; they just differ in how they are drawn. This is a perfect situation for an abstract superclass.
First you would declare an abstract class, GraphicObject, to provide member variables and methods that were wholly shared by all subclasses, such as the current position and the moveTo method. GraphicObject also declares abstract methods for methods, such as draw, that need to be implemented by all subclasses, but are implemented in entirely different ways (no default implementation in the superclass makes sense). The GraphicObject class would look something like this:
abstract class GraphicObject {int x, y;
. . .void moveTo(int newX, int newY) { . . . }abstract void draw();}Each non-abstract subclass of GraphicObject, such as Circle and Rectangle, would have to provide an implementation for the draw method. class Circle extends GraphicObject {void draw() { . . . }}class Rectangle extends GraphicObject { void draw() { . . . }}An abstract class is not required to have an abstract method in it. But any class that has an abstract method in it or that does not provide an implementation for any abstract methods declared in its superclasses must be declared as an abstract class.
22
Creating Interfaces
The Java programming language supports interfaces that you use to define a protocol of behavior that can be implemented by any class anywhere in the class hierarchy. What Is an Interface? This section defines the term "interface," shows you an example of an interface and how to use it, and talks about why you may need interfaces in your programs. Defining an Interface Defining an interface is similar to creating a new class. An interface definition has two components: the interface declaration and the interface body. interfaceDeclaration { interfaceBody}The interfaceDeclaration declares various attributes about the interface such as its name and whether it extends another interface. The interfaceBody contains the constant and method declarations within the interface. Implementing an Interface To use an interface, you write a class that implements the interface. When a class claims to implement an interface, the class is claiming that it provides a method implementation for all of the methods declared within the interface (and its superinterfaces). Using an Interface as a Type When you define a new interface you are in essence defining a new reference data type. You can use interface names anywhere you'd use any other type name: variable declarations, method parameters and so on. Warning! Interfaces Cannot Grow If you ship public interfaces to other programmers, here's a limitation of interfaces that you should be aware of: Interfaces cannot grow. Let's look at why this is the case.
Essential Java Classes
This trail discusses classes from the Java platform that are essential to most programmers. It focuses on classes in the java.lang and java.io packages, including these: Thread and its related classes Throwable and Exception, and their friends The Reader, Writer, InputStream, and OutputStream classes from java.io and their descendants Handling Errors Using Exceptions explains how you can use Java's exception mechanism to handle errors in your programs. This lesson describes what an exception is, how to throw and catch exceptions, what to do with an exception once you've caught it, and how to best use the exception class hierarchy provided by the Java platform. Threads: Doing Two or More Tasks at Once discusses in detail the use of threads that enable your Java applications or applets to perform multiple tasks simultaneously. This lesson describes when and why you might want to use threads, how to create and manage threads and thread groups in your Java program, and how to avoid common pitfalls such as deadlock, starvation, and race conditions. I/O: Reading and Writing (but No arithmetic) describes the process of getting information into your program and sending it out again through the use of the stream classes in java.io. Reading and writing information provides the basis for all kinds of interesting behaviors, such as serializing objects, communicating over a network, or just accessing the file system.
23
Setting Program Attributes describes how you can set attributes for your Java programs through the use of properties and command-line arguments. Use properties to change attributes for every invocation of your program; use command-line arguments to change attributes for only the current invocation of your program. Accessing System Resources shows you how, through the System class, your Java programs can manage properties, set up a security manager, and access system resources such as the standard input and output streams. The System class provides a system-independent programming interface to system resources, thus allowing your programs to use them without compromising portability. This lesson also contains a brief discussion of the Runtime class and why most programmers should avoid using it.
Java's Catch or Specify RequirementThis section discusses the reasoning behind this requirement and what it means to you and your Java programs. Dealing with ExceptionsThis section features an example program that can throw two different kinds of exceptions. Using this program, you can learn how to catch an exception and handle it and, alternatively, how to specify that your method can throw it.
Throwing ExceptionsThe Java runtime system and many classes from Java packages throw exceptions under some circumstances by using the throw statement. You can use the same mechanism to throw exceptions in your Java programs. This section shows you how to throw exceptions from your Java code. Runtime Exceptions--The ControversyAlthough Java requires that methods catch or specify checked exceptions, they do not have to catch or specify runtime exceptions, that is, exceptions that occur within the Java runtime system. Because catching or specifying an exception is extra work, programmers may be tempted to write code that throws only runtime exceptions and therefore doesn't have to catch or specify them. This is "exception abuse" and is not recommended. The last section in this lesson, explains why.
What Is a Thread ?
All programmers are familiar with writing sequential programs. You've probably written a program that displays "Hello World!" or sorts a list of names or computes a list of prime numbers. These are sequential programs. That is, each has a beginning, an execution sequence, and an end. At any given time during the runtime of the program, there is a single point of execution. A thread is similar to the sequential programs described previously. A single thread also has a beginning, a sequence, and an end and at any given time during the runtime of the thread, there is a single point of execution. However, a thread itself is not a program; it cannot run on its own. Rather, it runs within a program. The following figure shows this relationship.
24
Definition: A thread is a single sequential flow of control within a program. There is nothing new in the concept of a single thread. The real hoopla surrounding threads is not about a single sequential thread. Rather, it's about the use of multiple threads in a single program, running at the same time and performing different tasks. This is illustrated by the following figure:
The HotJava Web browser is an example of a multithreaded application. Within the HotJava browser you can scroll a page while it's downloading an applet or image, play animation and sound concurrently, print a page in the background while you download a new page, or watch three sorting algorithms race to the finish. You are used to life operating in a concurrent fashion...so why not your browser? Some texts use the name lightweight process instead of thread. A thread is similar to a real process in that a thread and a running program are both a single sequential flow of control. However, a thread is considered lightweight because it runs within the context of a full-blown program and takes advantage of the resources allocated for that program and the program's environment. As a sequential flow of control, a thread must carve out some of its own resources within a running program. (It must have its own execution stack and program counter for example.) The code running within the thread works only within that context. Thus, some other texts use execution context as a synonym for thread.
I/O Streams
To bring in information, a program opens a stream on an information source (a file, memory, a socket) and reads the information sequentially, as shown here:
Similarly, a program can send information to an external destination by opening a stream to a destination and writing the information out sequentially, like this:
25
No matter where the data is coming from or going to and no matter what its type, the algorithms for sequentially reading and writing data are basically the same:
Reading Writing
open a streamwhile more informationread informationclose the stream
open a streamwhile more informationwrite informationclose the stream
The java.io package contains a collection of stream classes that support these algorithms for reading and writing. To use these classes, a program needs to import the java.io package. The stream classes are divided into two class hierarchies, based on the data type (either characters or bytes) on which they operate.
Character Streams
Reader and Writer are the abstract superclasses for character streams in java.io. Reader provides the API and partial implementation for readers--streams that read 16-bit characters--and Writer provides the API and partial implementation for writers--streams that write 16-bit .
26
Byte Streams
To read and write 8-bit bytes, programs should use the byte streams, descendants of InputStream and OutputStream . InputStream and OutputStream provide the API and partial implementation for input streams (streams that read 8-bit bytes) and output streams (streams that write 8-bit bytes). These streams are typically used to read and write binary data such as images and sounds. Two of the byte stream classes, ObjectInputStream and ObjectOutputStream, are used for object serialization. These classes are covered in Object Serialization.
27
Message
A single object alone is generally not very useful. Instead, an object usually appears as a
component of a larger program or application that contains many other objects. Through the
interaction of these objects, programmers achieve higher-order functionality and more complex
behavior. Your bicycle hanging from a hook in the garage is just a bunch of titanium alloy and
rubber; by itself, the bicycle is incapable of any activity. The bicycle is useful only when another
object (you) interacts with it (pedal).
Software objects interact and communicate with each other by sending messages to each
other. When object A wants object B to perform one of B's methods, object A sends a message
to object B
28
FEASIBILITY ANALYSIS
A feasibility study is a test of a system proposal according to its workability,
impact on the organization, ability to meet user needs, and effective use of
resources. It focuses on identifying and evaluating alternative candidate system
with a recommendation of the best system for the jab. The feasibility study is
conducted to evaluate the feasibility of the candidate systems to produce the
desired outputs. Most successful system projects are not necessarily the biggest
or most visible in a business but rather those that truly meets user expectation.
Three key considerations are involved in the feasibility study.
Economical Feasibility:
Economic analysis is the most frequent used method for evaluating the
effectiveness of a candidate system. Most commonly known as cost/benefit
analysis, the procedure is to determine the benefits and savings that are expected
from a candidate system and compare them with cost. If benefits outweigh costs,
then the decision is made to design and implement the system.
Behavioral Feasibility:
People are inherently resistant to change, and the computers have been
known to facilitate change. An adverse reaction and resistance is always from the
user staff. In case our candidate system the case is different. An estimate should
be made of how strong a reaction a user staff is likely to have a development of a
29
computerized system. On the basis of the feasibility analysis it is recommended
that the project may be approved from design, development implementation.
Technical Feasibility:
Technical feasibility centers on the existing computer system and to what
extent it can support the proposed systems in case of our candidate system the
required technical know how already exists.
SRS
The software requirement specification is produced at the culmination of the
analysis task. The function and performance allocated to software as part of
system engineering are refined by establishing a complete information
description, a detailed functional description, a representation of system
behavior, an indication of performance requirement and design
constraints appropriate validation criteria, and other information
pertinent to requirement.
The introduction to software requirements specification states the goals
and objectives of the software, describing it in the context of the computer
based system.
The Information Description provides a detailed description of the
problem that the software must solve. Information content, flow and
structure are documented.
A description of each function required to solve the problem is presented
in the Functional Description.
Validation Criteria is probably the most important and ironically the
most often neglected section of the software requirement specification.
Software requirement specification can be used for different purpose.
Here are the major uses.
Statement of user needs:
30
A main purpose of the product specification is to define the need of the
product’s user. Some times, the specification may be a part of a contract
sign between the producer and the user. It could also form part of the
user manuals. A user‘s needs are sometimes not clearly understood by
the developer. If this is the case, a careful analysis – involving much
interaction with the user should be devoted to reaching a clear statement
of requirements, in order to avoid possible misunderstandings.
Sometimes, at the beginning of a project, even the user has no clear idea
of what exactly the desired product is. Think for instance of user interface
, a user with no previous experience with computer products may not
appreciate the difference between , say menu driven interaction and a
command line interface. Even an exact formation of system functions and
performance may be missing an initial description produced by an
inexperienced user.
A statement of the requirements for the implementation:
Specifications are also used as a reference point during product
implementation. In fact, the ultimate goal of the implementation is to
build a product that needs specification. Thus the implementers use
specifications during design to make design decisions and during the
verification activity to check that the implementation compiles with
specifications.
31
INTRODUCTION
System design is the process of developing specifications for a candidate system
that meet the criteria established in the system analysis. Major step in system
design is the preparation of the input forms and the output reports in a form
applicable to the user.
The main objective of the system design is to make the system user friendly.
System design involves various stages as:
Data Entry
Data Correction
Data Deletion
Processing
Sorting and Indexing
Report Generation
System design is the creative act of invention, developing new inputs, a database,
offline files, procedures and output for processing business to meet an organization
objective. System design builds information gathered during the system analysis.
32
CHARACTERSTICS OF A WELL DEFINED SYSTEM
In design an efficient and effective system is of great importance to
consider the human factor and equipment that these will require to use.
System analyst must evaluate the capabilities and limitations of the
personal and corresponding factors of the equipment itself.
The characteristics associated with effective system operations are:
Accessibility
Decision Making Ability
Economy
Flexibility
Reliability
Simplicity
Success is a new system pivots on its acceptance or non-acceptance by the
organization.
Personnel:
If the operating system is convinced that the new system will not benefit
them, it appears one, and the system is in serious trouble. To overcome
this resistance participation by operating personal during all phases of
the changeover is necessary because they constitute the organization,
which must use alive in with newly design system. An effective system
produces not only information at the lowest cost pertinent and timely for
making decision.
33
DATABASE DESIGN:
The overall objective in the development of the database technology has
been to treat data as an organizational resource and as an integrated
whole. Database management system allows data to be protected and
organize separately from other resources. Database is an integrated
collection of data. The most significant of data as seen by the programs
and data as stored on the direct storage access storage devices. This is the
difference between logical and physical data. The organization of data in
the database aims to achieve free major objectives:
Data Integration
Data Integrity
Data Independence
The databases are implemented using a DBMS package. Each particular
DBMS has unique characteristics and general techniques for Database
Design.
The proposed Management Information System stores the information
relevant for processing in the Microsoft SQL Server Database. This MS
SQL Server contains tables, where each table is called a field or column.
A table also contains records which is a set of fields. All records, in a table
the same set of fields with different information. Each table contains key
fields that establish relationships in a MS SQL server database and how
the records are stored. There are primary key fields that uniquely
identify a record in a table. There are also fields that contain the primary
key from another table called foreign keys.
It is a known fact that the program cannot be written until the data are
defined, so the database must be defined. The starting point for this
process is data dictionary. The records data structures and elements to be
stored in each database are identified and extracted. Next the analyst
codes the source statements library. Eventually, the programmer will
34
incorporate the source code into the various programs, thus assuring
consistency and simplifying the coding process. The databases have been
designed in such a way that there is no duplication of information and loss
of information.
35
SCHEMA DESIGN:
INTRODUCTION:
In database design, several views of data must be considered along with
the persons who use them. In addition to data structuring, where
relationships are reflected between and within entities, we need to identify
the application program’s logical views of data within an overall logical
data structure. The logical view is what the data look like, regardless of
how they are stored. The physical view is the way data exist in physical
storage. It deals with hoe data are stored, accessed, or related to other
data in storage.
The schema is the view that helps the DBMS decide in storage act upon as
requested by the application program.
RELATIONAL MODEL:
Certain rules followed in creating and relating databases in the relational
databases. This governs how to relate data and prevent redundancy of the
data in the databases. The first set of rules called relational rules ensures
that the database is a relational database. The second set called the
normalization rules simplifies the database and reduce the redundancy of
the data.
36
Proposed system this relational database rules are applied to reduce the
redundancy make future changes to the table structure easier to and
minimize the impact of these changes on users interface to the database.
This is done first determining what information is needed, how items are
related, what constraints are established. Tables are created and linked
by appropriate key fields. The constraints on the data are used to guide
the building of tables. The tables are created by making use of the
normalization principles. The proposed system has its own tables in the
third normal form.
CODE DESIGN
When large volumes of data are being handled, it is important that the
item be identified, stored or selected easily and quickly. To accomplish
this, each data item must have unique identification and must be related
to other items of the same type. Codes can provide brief identification of
each item, which replace longer description that would be more awkward
to store and manipulate.
The ability to interrupt codes, evaluate coding schemes and devices new
or improved codes are important skills for a system analyst. Common
types of codes are:
SEQUENCE CODES:
A sequence code has no relation to the characteristics of an item. Here a
dictionary is required. The data is arranged alphabetically and numbered
sequentially. When a new data item is added it is given the next sequence
number. The advantage of this code is that it has the ability touched with
an unlimited number of digits.
37
SIGNIFICANT DIGIT CODE:
It is a code in which the number describes measurable physical
characteristics of the item.
ALPHABETIC CODE:
Here, the item are specified by the user of letter and number
combinations,
SELF CHECKING CODE:
It uses a check digit to check the validity of codes. These types of codes
are an important means of controlling the validity of data that are being
processed.
VALIDATION CHECKS:
A common problem with computer system is that it is very easy to put
incorrect data into them. So the input data is validated to minimize errors
and data entry. For certain data specific code has been given and
validations are done which enable the user to enter the required data and
correct them if they have entered wrong codes, e.g. you could mistype a
link name or a URL in a database resulting in reports being occurred in
the wrong link name. if you put incorrect data into the computer system
then you will get incorrect results out of it. Processing incorrect inputs
will produce incorrect outputs. This lead to the acronym: GIGO
(Garbage In Garbage Out).
Sometimes incorrect data can actually cause a computer system to stop
work temporarily. This is a particular problem in batch processing
38
systems when data may be processed overnights. If incorrect data stops a
batch processing systems for working then a whole night processing time
may be lost.
People who develop computer systems go to a lot of trouble to make it
difficult for incorrect data to be entered. The two main techniques used
for this purpose are:
VERIFICATION
VALIDATION
VERIFICATION:
A verification check ensures that data i9s correctly transferred into a
computer from the medium that it was originally stored on. Verification
checks are usually used to check that a data entry worker has correctly
typed information written on a data collection form into a computer.
Methods of Verification:
The two most common methods of verification are:
On-Screen prompts: After a user has entered some data it is
redisplayed on the screen. The user is prompted to read the
data and confirm that it has been entered correctly. If the user
has entered any data incorrectly he should response that the
data is inaccurate and retypes the incorrect parts.
Dual Inputs: This method is used when data is entered through
the keyboard. The data to be entered is typed in twice by two
different operations. The two copies of data are been
compared, any difference are detected, the operators will be
prompted to retype the sections that differ until both copies
39
agree/. When the two copies agree the computer assumes that
the data has been entered correctly.
VALIDATION:
A validation check is an automatic check made by computer to ensure
that any data entered into the computer is sensible. A validation check
does not make sure that data has been entered correctly. It only ensures
that data is sensible. For this reason validation checks are not usually as
effective as verification checks. They can however be carried out
automatically by the computer and therefore require less work by the
computer operators making them cheaper to use.
Methods of validation:
There are many different methods of validations. The most appropriate
method to use will depend upon what data is being entered. The most
common methods are listed here.
Presence Checks: checks that data has been entered into the
field and that it has not been left blank, e.g. checks that Project
ID is always entered into each record in a database of project
details.
Type Checks: checks that an entered value is of particular
type. E.g. checks that a field is varchar, a number, etc.
Length Checks: checks that an entered value, e.g. Project ID is
no longer than a particular number of characters.
Format Checks: Checks that an entered value has a particular
format. E.g. a date must be consist of “mm-dd-yy” format.
Validation checks can be performed by any piece of software. If the user
tries to do unauthorized operations the appropriate error messages are
40
IMPLEMENTATION
INTRODUCTION:
Implementation is the stage in the project where the theoretical design is
turned into the working system and is giving confidence to the new system
for the users i.e. will work efficiently and effectively. It involves careful
planning, investigation of the current system and its constraints on
implementation, design of method to achieve the change over, an
evaluation, of change over methods. A part from planning major task of
preparing the implementation is education of users. The more complex
system is implemented, the more involved will be the system analysis and
design effort required just for implementation. An implementation
coordinating committee based on policies of individual organization has
been appointed. The implementation process begins with preparing a
plan for the implementation for the system. According to this plan, the
activities are to be carried out, discussions may regarding the equipment
has to be acquired to implement the new system.
Implementation is the final and important phase. The most critical stage is
in achieving a successful new system and in giving the users confidence that
the new system will work and be effective. The system can be implemented
only after thorough testing is done and if it found to working according to
the specification. This method also offers the greatest security since the old
system can take over if the errors are found or inability to handle certain
types of transaction while using the new system.
43
At the beginning of the development phase a preliminary implementation
plan is created to schedule and manage the many different activities that
must be integrated into plan. The implementation plan is updated
throughout the development phase, culminating in a change over plan for
the operation phase. The major elements of implementation plan are test
plan, training plan, equipment installation plan, and a conversion plan.
There are three types of implementation:
o Implementation of a computer system to replace a manual system.
o Implementation of a new computer system to replace an existing
system.
o Implementation of a modified application to replace an existing
one, using the same computer.
Successful implementation may not guarantee improvement in the
organization using the new system, but improper installation will prevent
it. It has been observed that even the best system cannot show good result
if the analysts managing the implementation do not attend to every
important detail. This is an area where the systems analysts need to work
with utmost care.
IMPLEMENTATION TOOLS:
Training personnel
Conversion Procedures
Post-implementation review
Training of Personnel involved with system
Even well designed system can succeed or fail because of the way they are
operated and used. Therefore, the quality of training received by the
44
personal involved with the system in various capacities helps or hinders
and may even prevent the successful implementation of management
information system.
Those who are directly or indirectly related with the system development
work must know in detail what must know in detail what their roles will
be, how they can make efficient use of the system and what the system will
or will not do for them. Both system operators and users need training.
System Operators Training
Running of the system successfully depend on the personnel working in
the Computer Centre. They are Responsible for providing the necessary
support. Their training must ensure that they are able to handle all
possible operations, both routine and extra-ordinary in nature.
If the system calls for the installation of new equipment, such as new
computer system, special terminals or different data entry machines, the
operators training should include such fundamentals as how to turn the
equipment on and use it, how to power off and a knowledge of what
constitutes normal operations. The operators should also be trained on
different type of malfunctioning, how to recognize them and what steps
should also be taken whenever they arise.
User Training
User may be trained on use equipment, particularly in the case where, e.g.
a micro computer is in use and individual involved is both operator and
user. In such cases, user must be given training on how to operate and
user. In such cases, user must be given training on how to operator the
system also. Questions that may be trivial to the analyst, such as how to
turn on a terminal, how to insert a diskette into a micro-computer or
when it is safe to turn off equipment with out danger of data loss are
significant problems to new users who are not familiar.
45
Inmost of the cases user training deals with the operation of the system
itself, with proper attention given to data handling techniques. It is
imperative that users be properly trained in methods of entering
transaction, editing data, formulating inquiries, deleting and inserting of
records. No training is complete without familiarizing users with simple
systems maintenance activities. Weakness in any aspect of training may
lead of awkward situation that creates user frustration and error.
Conversion Methods
A conversion is the process of changing from the old system to the new
one. It must be properly planned and executed. Four methods are
common in use. They are Parallel Systems, Direct Conversion, Pilot
System and Phase In method. Each method should be considered in the
light of the opportunities that it offers and problems that it may create. In
general, system conversion should be accomplished in shortest possible
time. Long conversion periods create problems for all persons involved
including both analysts and users.
Parallel systems:
The most secure method of converting from an old to new system is to run
both systems in parallel. This method is safest one because it ensures that
in case of any problem in using new system, the organization can still fall
back to the old system without the loss of time and money.
The disadvantages of parallel systems approach are:
It doubles operating costs.
The new system may not get fair trial.
Direct conversion:
46
This method converts from the old system to new system abruptly,
sometimes over a weekend or even overnight. The old system is used until
a planned conversion day, when it is replaced by the new system.
Pilot system:
Pilot approach is often preferred in the case of the new system which
involves new techniques or some drastic changes in organization
performance. In this method, a working version of the system is
implemented in one part of the organization, such as a single work area
or department.
Phase –IN- method:
This method is used when it is not possible to install a new system
throughout an organization all at once. The conversion of files, training of
personnel or arrival of equipment may force the staging of the
implementation over a period of time, ranging from weeks to months.
POST IMPLEMENTATION REVIEW
After the system is implemented and conversion is complete, a review
should be conducted to determine whether the system is meeting
expectations and where improvements are needed. A post implementation
review measures the systems performance against predefined
requirement. It determines how well the system continues to meet the
performance specifications.
47
SYSTEM TESTING
INTRODUCTION:
The purpose of system testing is to identify and correct errors in the
candidate system. Testing is and important element of software quality
assurance ad represents the ultimate review of specification, design and
coding. The increasing visibility of the software as a system element and
the cost associated with a software failure are motivated forces for well
planned, through testing.
System testing was conducted in order to detect errors and for comparing
then the final system with the requirement specification reports, i.e.
whether the system meets requirements. During testing the software was
executed with the set of test cases and the output of programs for the test
cases was evaluated to determine if the program is performing as it was
expected to.
Testing presents an interesting challenge for the software engineers
attempt to build software from an abstract concept to an acceptable
implementation. In testing engineer create a series of test cases that
occurs when errors are uncovered. Testing is the process of executing a
program for finding errors. A good test is one that has the high
probability of finding an uncovered error. A successful error is one that
uncovers undiscovered errors.
The term error is used to refer the difference between actual output of the
software and the current output. Fault is a condition that causes the
software to fail to perform its required function. Software reliability is
defined as a required function. Software reliability is defined as the
probability that the software will not undergoes failures for a specified
times under specified condition. Failure is the inability of a system or a
component to perform a required function according to its specification.
Different levels of testing were employed for software to make it error
free, fault free and reliable.
48
Unit Testing:
Unit testing was conducted first. Different modules of the software were
tested against the specifications produced during design of the modules.
Verification of the code produced during the coding phase was done.
Each module was tested separately.
Unit testing focuses verification effort on the smallest unit of software
design module. This uncovers errors within the boundary of a module.
Unit testing is actually White box testing both the external things as well
as the internal codes are tested. In testing, the interfaces are tested in
order to ensure the proper flow of data in and out of the module. The
boundary testing is done to ensure that the module keeps the limit of it.
All independent paths are tested to ensure that all statements are tested at
least once. At last the error path is also tested.
Unit testing comprises the set of tests performed by an individual
programmer prior to integration of the unit into a larger system. There
are four categories of test that can be performed on a program unit
Functional Unit
Performance Unit
Stress Unit
Structure Unit
Then system testing was conducted. Here the entire software system was
tested.
The reference document used for this process was requirement document and
the goal was to see if the software meets its requirements.
System testing includes the thorough testing of the product. System testing is
actually a series of different tests whose primary purpose is to fully exercise
the computer based system. The tests are recovery testing: this checks the
recovery of the system when failure occurs. This is to ensure that there are
recovery procedures for error occurrences.
49
System testing involves unit testing, integration testing, acceptance
testing. Careful planning and scheduling are required to ensure that
modules will be available for integration into the evolving software
product when needed. A test plan has the following steps:
Prepare test plan
Specify conditions for user acceptance testing
Prepare test data for program testing
Prepare test data for transaction path testing
Plan user testing
Compile/Assemble program
Prepare job performance aids
Prepare operational documents
Objectives of testing.
First of all objectives should be clear.
Testing as a process of executing a program with the intent of finding
errors.
To perform testing, test cases are designed. A test case is a particular
made up of artificial situation upon which a program is exposed so as to
find errors. So a good test case is one that finds undiscovered errors.
If testing is done properly, it uncovers errors and after fixing those errors
we have software that is being developed according to specifications.
The above objective implies a dramatic change in viewpoint .The move counter
to the commonly held view than a successful test is one in which no errors are
found. In fact, our objective is to design tests that a systematically uncover
different classes of errors and do so with a minimum amount of time and effort.
Testing principles
Before applying methods to design effective test cases, software engineer must
understand the basic principles that guide the software testing process. Some of
the most commonly followed principles are:
50
All test should be traceable to customer requirements as the objective of testing
is to uncover errors, it follows that the most severe defects (from the customers
point of view) are those that causes the program to fail to meet its requirements.
Tests should be planned long before the testing begins. Test planning can begin
as soon as the requirement model is complete. Detailed definition of test cases
can begin as soon as the design model has been solidated. Therefore, all tests can
be planned and designed before any code can be generated.
The Pareto principle applies to software testing stated simply the Pareto
principle implies that 80 percent of all errors uncovered during testing will likely
be traceable to 20 percent of all program modules. The problem of course, is to
isolate these suspects’ modules and to thoroughly test them.
Testing should begin “in the small “and progress towards testing “in large”. The
first tests planned and executed generally focus on individual modules. As testing
progresses, testing shifts focus in an attempt to find errors in integrated clusters
of modules and ultimately in the entire system.
Exhaustive testing is not possible. The number of paths permutations for
impossible to execute every combination of paths during testing. It is possible
however to adequately cover program logic and to ensure that all conditions in
the procedural design have been exercised.
To be most effective, an independent third party should conduct testing. By
“most effective”, we mean testing that has the highest probability of finding
errors (the primary objective of testing).
Software project management is an umbrella activity within software
engineering. It begins before any technical activity is intimated and continues
throughout the definition, development, and maintenance of computer software.
51
Three p’s 1 have a substantial influence on software project management –
people, problem, and process. People must be organized into effective teams,
motivated to do high quality software work, and coordinated to achieve effective
communication. The problem communicated from customer to developer,
partitioned (decomposed) into its constitute parts, and positioned for work by
the software team. The process must be adapted to the people and the problem.
A common process framework is selected, an appropriate software engineering
paradigm is applied, and a set of work is chosen to get the job done.
The pivotal element in all software projects is people. Software engineers can be
organized in a number of different team structures that range from traditional
control hierarchies to “Open paradigm” team. A variety of coordination and
communication techniques can be applied to support the work of the team. In
general, formal reviews and informal person-to-person communication have the
most value for the practitioners.
The project management activity encompasses measurement and metrics,
estimation, risk analysis, schedules, tracking and control, and control. Each of
these steps was followed during project also.
Test information flow
Testing is a complete process. For testing we need two types of inputs:
Software configuration –it includes software requirement specification, design
specification and source code of program. Software configuration is required so
that testers know what is to be expected and tested.
Test configuration – it is basically test plan and procedure. Test configuration is
testing plan that is, the way how the testing will be conducted on the system. It
specifies the test cases and their expected value. It also specifies if any tools for
testing are to be used.
52
Test cases are required to know what specific situations need to be tested. When
tests are evaluated, test results are compared with actual results and if there is
some error, then debugging is done to correct the error. Testing is a way to know
about quality and reliability. Error rate that is the occurrence of errors is
evaluated. This data can be used to predict the occurrence of errors in future.
Test case design
We know, test cases are integral part of testing. So we need to know more about
test cases and how these test cases are designed. The most desired or obvious
expectation from the test cases is that it should be able to find most errors with
the least amount of time and effort.
A software product can be tested in two ways. In first approach, only overall
functioning of the product is tested. Inputs are given and outputs ate checked.
This approach is called black box testing. It does not care about the internal
functioning of the product.
The other approach is called white box testing. Here the internal functioning of
he product is tested. Each procedure is tested for its accuracy. It is more
intensive than black box testing. But for the overall product both these
techniques are crucial. There should be sufficient number of tests in both
categories to test the overall product.
Basic methods of Testing
White box testing
White box testing is performed to reveal problems with the internal structure of
a program. This requires the tester to have detailed knowledge of the internal
structure. A common goal of white box testing is to ensure a test case exercises
every path through a program. A fundamental strength that all white box
strategies share is that the entire software implementation is taken into account
during testing, which facilitates error detection even when software specification
is vague or incomplete. The effectiveness or thoroughness of white box testing is
commonly expressed in terms of test or code coverage metrics, which measure
the fraction of code exercised by test cases.
53
Basic Path Testing
It is a white box technique. It was proposed by Tom McCabe. These tests
guarantee to execute every statement in the program at least one time during
testing. Basic set is the set of all execution paths of a procedure.
Black Box Testing
Black box tests are performed to access how well a program meets its
requirements, looking for incorrect or missing functionality. Functional tests
typically exercise code with valid or nearly valid input for which the expected
output is known. This includes concepts such as ‘boundary values’.
Performance tests evaluate response time, memory usage, throughput, device
utilization and execution time. Stress tests push the system to or beyond its
specified limits to evaluate its robustness and error handling capabilities.
Reliability tests monitor system response to representative user input, counting
failures over time to measure or certify reliability.
Black box testing uncovers the following types of errors
Incorrect or missing functions
Interface errors
External database access
Performance errors
Initialization and termination errors
The following techniques are employed during black box testing
Integration Testing
One of the most difficult aspects of software development is the integration and testing of large untested subsystems the integrated system frequently fails in significant ands mysterious ways, and it is difficult to fix it.Integration testing exercises several units that have been combined to form a module, subsystem or system. Integration testing focuses on the interfaces between units, to make sure the units work together. The nature of this phase is certainly ‘white box’, as we must have knowledge of the units to recognize if we have been successful in focusing them together in the module.
54
The system has been developed for the given condition and is
found working effectively. The developed system is flexible and
changes whenever can be made easy. Using the facilities and
functionalities of .Net, the software has been developed in a neat
and simple manner, thereby reducing the operators work.
The speed and accuracy are maintained in proper way. The user
friendly nature of this software developed in .Net framework is
very easy to work with both for the higher management as well as
other employees with little knowledge of computer. The results
obtained were fully satisfactory from the user point of view.
The system was verified with valid as well as invalid data in each manner. the
system is run with an insight into the necessary modifications that may require in
the future. Hence the system can be maintained successfully without much network
56
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
/** * * */import java.io.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;//import java.util.*;//import java.lang.*;//import java.applet.*;public class nbrush3 extends JFrame implements ActionListener {
JLabel jl; JButton bLine, bRect, bOval; Color c; int x1, y1, x2, y2; String msg = " "; int mouseX = 0, mouseY = 0; JFileChooser fc; File file;
public nbrush3() { super("hello");
Container cont = new Container(); jl = new JLabel(" "); JPanel pbuttons = new JPanel(); DrawingPanel drp = new DrawingPanel(); //JPanel pDraw = new JPanel(); JPanel pStatus = new JPanel();
57
fc = new JFileChooser();
//...buttons............................................................................................... pbuttons.setLayout(new GridLayout(9, 2)); GridLayout gl = new GridLayout(9, 2);
bLine = new JButton("line"); bRect = new JButton("rect"); bOval = new JButton("oval");
pbuttons.add(bLine); pbuttons.add(bRect); pbuttons.add(bOval);
//......................................................menu bar........................ JMenuBar mbr = new JMenuBar(); setJMenuBar(mbr); JMenu filem = new JMenu("FILE"); JMenu edit = new JMenu("EDIT"); JMenu view = new JMenu("VIEW"); JMenu image = new JMenu("IMAGE"); JMenu colors = new JMenu("COLORS"); JMenu help = new JMenu("HELP");
//............................................................file menu............. JMenuItem mit, mit1, mit2, mit3, mit4; filem.add(mit = new JMenuItem("new")); filem.add(mit1 = new JMenuItem("open")); filem.add(mit2 = new JMenuItem("save")); filem.add(mit3 = new JMenuItem("save as")); filem.add(mit4 = new JMenuItem("exit"));
58
//..............................................................edit menu.............
JMenuItem mit5, mit6, mit7, mit8, mit9; edit.add(mit5 = new JMenuItem("undo")); edit.add(mit6 = new JMenuItem("redo")); edit.add(mit7 = new JMenuItem("cut")); edit.add(mit8 = new JMenuItem("copy")); edit.add(mit9 = new JMenuItem("paste"));
JMenuItem bc; colors.add(bc = new JMenuItem("setbackground")); bc.addActionListener(new MyAction());
bLine.addActionListener(drp);
bRect.addActionListener(drp);
bOval.addActionListener(drp);
mit.addActionListener(new MyAction());
mit1.addActionListener(new MyAction());
mit2.addActionListener(new MyAction());
mit3.addActionListener(new MyAction());
mit4.addActionListener(new MyAction());
mit5.addActionListener(new ActionListener() {
59
public void actionPerformed(ActionEvent ae) { jl.setText("undo is clicked"); } });
mit6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) { jl.setText("redo is clicked"); } });
mit7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) { jl.setText("cut is clicked");
} }); mit8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) { jl.setText("copy as is clicked"); } }); mit9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) { jl.setText("paste is clicked"); } });
mbr.add(filem); mbr.add(edit); mbr.add(view); mbr.add(image);
60
mbr.add(colors); mbr.add(help); cont = getContentPane(); cont.setLayout(new BorderLayout()); cont.add(mbr, BorderLayout.NORTH); cont.add(pbuttons, BorderLayout.WEST); cont.add(drp, BorderLayout.CENTER); cont.add(jl, BorderLayout.SOUTH);
setSize(660, 490); this.setResizable(true); setVisible(true); } //.......end of nbrush constructor
class DrawingPanel extends JPanel implements ActionListener {
int chr = 0;
DrawingPanel() { MouseHandler handler = new MouseHandler(); this.addMouseListener(handler); this.addMouseMotionListener(handler);
/*----------------------------------------------------------------------------*/ addWindowListener( new WindowAdapter() {
@Override public void windowClosing(WindowEvent e) { System.exit(0); } });
setBackground(Color.white);
61
setForeground(Color.black);
}
@Override public void paintComponent(Graphics g) { super.paintComponent(g); switch (chr) { case 1:
g.drawLine(x1, y1, x2, y2);
break; case 2:
g.drawRect(x1, y1, x2, y2);
break; case 3:
g.drawOval(x1, y1, x2, y2);
break; } } // end paintComponent
public void actionPerformed(ActionEvent ae) { String command = ae.getActionCommand(); if (command.equals("line")) { chr = 1;
} if (command.equals("rect")) { chr = 2; } if (command.equals("oval")) { chr = 3;
62
} } }
/*-----------------------------------------------------------------------giving event sfor file,edit,...etc--------------*/ public class MyAction implements ActionListener {
public void actionPerformed(ActionEvent ae) { String str = ae.getActionCommand(); if (str.equals("new")) { //JOptionPane.showMessageDialog(null, "hello", "new", 1); //pDraw.clear(); //pDraw.setDrawmode(0); //pDraw.setForeground(Color.WHITE); //pDraw.setBackground(Color.BLACK); //pDraw.repaint(); } if (str.equals("open")) { int returnVal = fc.showOpenDialog(nbrush3.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); } else { } // log.setCaretPosition(log.getDocument().getLength()); } if (str.equals("save")) { int returnVal = fc.showSaveDialog(nbrush3.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); } else { } // log.setCaretPosition(log.getDocument().getLength());
63
}
if (str.equals("save as")) { int returnVal = fc.showSaveDialog(nbrush3.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); } else { } // log.setCaretPosition(log.getDocument().getLength()); } if (str.equals("setbackground")) { Color c = JColorChooser.showDialog( nbrush3.this, "Choose a color...", getBackground()); if (c != null) { getContentPane().setBackground(c); } } if (str.equals("exit")) { System.exit(0);
} } } /*----------------------------------------------------------------------------*/
private class MouseHandler implements MouseListener, MouseMotionListener {
public void mouseClicked(MouseEvent me) { //mouseX=0; //mouseY=0; jl.setText("mouse clicked"); //repaint(); }
64
public void mouseEntered(MouseEvent me) { mouseX = 0; mouseY = 0; jl.setText("mouse enetered"); //repaint(); }
public void mouseExited(MouseEvent me) { mouseX = 0; mouseY = 0; jl.setText("mouse exited"); //repaint(); }
public void mousePressed(MouseEvent me) { mouseX = me.getX(); x1 = mouseX; mouseY = me.getY(); y1 = mouseY; jl.setText(mouseX + " , " + mouseY); //repaint(); }
public void mouseReleased(MouseEvent me) { mouseX = me.getX(); x2 = mouseX; mouseY = me.getY(); y2 = mouseY; jl.setText(mouseX + " , " + mouseY); repaint(); }
public void mouseDragged(MouseEvent me) { mouseX = me.getX(); mouseY = me.getY(); msg = "*";
65
jl.setText("Draggingmouse at " + mouseX + " , " + mouseY); //repaint(); }
public void mouseMoved(MouseEvent me) { jl.setText("movingmouse at " + me.getX() + " , " + me.getY()); }
public void paint(Graphics g) { g.drawString(" ", mouseX, mouseY); } }
public void actionPerformed(ActionEvent ae) { }
public static void main(String args[]) { nbrush3 dp = new nbrush3(); dp.setVisible(true); dp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }}
66
BIBLIOGRAPHY
Sr.No. Name of the Book Author’s Name
1. The Complete Reference Herbert Schildt
2. Programming with Java E. Balagurusamy
3. System Analysis and Design Elias M. Awad
Websites:
www.w3schools.com
www.wikipedia.com
www.google.com
68