Class: the unit of definition of data and behaviour (functionality) for some kind-of-thing. For example, the 'class of Dogs' might be a which includes the various breeds of dogs. A class is the basis of and in an object-oriented computer program. A class should typically be recognizable to a non-programmer familiar with the problem domain, and the code for a class should be (relatively) self-contained and independent (as should the code for any good pre-OOP ). With such modularity, the structure of a program will correspond to the of the that the program is intended to solve. This simplifies the to and from the problem and program.
: an instance of a class, an object (for example, "Lassie" the Dog) is the run-time manifestation (instantiation) of a particular exemplar of a class. (For the class of dogs which contains breed types, an acceptable exemplar would only be the subclass 'collie'; "Lassie" would then be an object in that subclass.) Each object has its own data, though the code within a class (or a subclass or an object) may be shared for economy. .
(also known as message) — how code can use an object of some class. A method is form of operating on a single object. Methods may be divided into queries returning the current state and commands changing it: a Dog could have a query Age to say how old it is, and command chase (Rabbit target) to start it chasing a rabbit. A method may also do both, but some authorities (e.g. ) recommend they be kept separate. Sometimes access to the data of an object is restricted to the methods of its class. A member of a class or object is a method or a data item describing the state of an object. In some languages the general term is feature.
— a mechanism for creating subclasses, inheritance provides a way to define a (sub) class as a specialization or subtype or extension of a more general class: Dog is a subclass of Canidae, and Collie is a subclass of the (sub) class Dog. A subclass inherits all the members of its super class (es), but it can extend their behaviour and add new members. Inheritance is the "is-a" relationship: a Dog is a Canidae. This is in contrast to , the "has-a" relationship: a Dog has a mother (another Dog) and has a father, etc.
– a Dog is both a Pet and a Canidae – is not always supported, as it can be hard both to implement and to use well.
— ensuring that code outside a class sees only functional details of that class, but not implementation details. The latter are liable to change, and could allow a user to put an object in an inappropriate state. Encapsulation is achieved by specifying which classes may use the members of an object. The result is that each object exposes to any class a certain — those members accessible to that class. For example, an interface can ensure that puppies can only be added to an object of the class Dog by code in that class. Members are often specified as public, protected and private, determining whether they are available to all classes, sub-classes or only the defining class. Some languages go further: reserves some members to classes in the same package, and allows one to specify which classes may access any member.
— the ability of a program to ignore the details of an object's (sub) class and work at a more generic level when appropriate; For example, "Lassie" the Dog may be treated as a Dog much of the time, but when appropriate she is abstracted to the level of Canidae (super class of Dog) or Carnivora (superclass of Canidae), and so on.
— polymorphism is behaviour that varies depending on the class in which the behaviour is invoked, that is, two or more classes can react differently to the same message. For example, if Dog is commanded to speak this may elicit a Bark; if Pig is commanded to speak this may elicit a Grunt.
Classes
In object-oriented programming, classes are used to group related variables and functions. A class describes a collection of encapsulated instance variables and methods (functions), possibly with implementation of those types together with a constructor function that can be used to create objects of the class.
A class is a cohesive package that consists of a particular kind of compile-time metadata. It describes the rules by which objects behave; these objects are referred to as "instances" of that class. A class specifies the structure of data which each instance contains as well as the methods (functions) which manipulate the data of the object and perform tasks; such methods are sometimes described as "behavior".
A method is a function with a special property that it has access to data stored in an object. A class is the most specific type of an object in relation to a specific layer. A class may also have a representation (met object) at run-time, which provides run-time support for manipulating the class-related metadata.
Instances of a class will have certain aspects (aka: features, attributes or properties) in common. A class Person for example would describe the properties common to all instances of the Person class. One of the benefits of programming with classes is that all instances of a particular class will follow the defined behavior of the class they instantiate.
Each person is generally alike; but varies in such properties as "height" and "weight". The class would list types of such instance variables; and also define, via methods, the actions which humans can perform: "run", "jump", "sleep", "throw object", etc.
In Object-Oriented Programming (OOP), an instance of a program (i.e. a program running in a computer) is treated as a dynamic set of interacting objects. Objects in OOP extend the more general notion of objects described above to include a very specific kind of typing, which among other things allows for:
Data members that represent the data associated with the object.
Methods that access the data members in predefined ways.
In the case of most objects, one can access the data members only through the method members, making it easy to guarantee that the data will always remain in a well-defined state (class invariants will be enforced). Some languages do not make distinctions between data members and methods.
Instance
In a language where each object is created from a class, an object is called an instance of that class. If each object has a type, two objects with the same class would have the same data type. Creating an instance of a class is sometimes referred to as instantiating the class.
Three properties characterize objects:
- identity - the property of an object that distinguishes it from other objects
- state - describes the data stored in the object
- behavior - describes the methods in the object's interface by which the object can be used
Some terms for specialized kinds of objects include:
- Singleton object - An object that is the only instance of its class during the lifetime of the program.
- Functor (function object) - an object with a single method (in C++, this method would be the function operator, "operator ()") that acts much like a function (like a C/C++ pointer to a function).
- Immutable object - an object set up with a fixed state at creation time and which does not vary afterward.
- First-class object - an object that can be used without restriction.
- Container object - an object that can contain other objects.
- Factory object - an object whose purpose is to create other objects
- Metobject - an object from which other objects can be created (Compare with class, which is not necessarily an object)
- Prototype - a specialized metaobject from which other objects can be created by copying
Instantiation
It refers to
Instantiation principle - the idea that if properties exist, the essence that "has" the properties must necessarily exist.
A concept in object-oriented programming, see Instance (programming), object lifetime
The first moment of existence of a thing, whether living or not. The concept of the big bang theory, at the instant it happened, represents the instantiation of the universe.
Advantages of JAVA
Java has gained enormous popularity since it first appeared. Its rapid ascension and wide acceptance can be traced to its design and programming features, particularly in its promise that write a program once, and run it anywhere. Java was chosen as the programming language for network computers (NC) and has been perceived as a universal front end for the enterprise database. As stated in Java language white paper by Sun Microsystems: "Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture neutral, portable, multithreaded, and dynamic."
Simplicity
No language is simple, but Java considered a much simpler and easy to use object-oriented programming language when compared to the popular programming language, C++. Partially modelled after C++, Java has replaced the complexity of multiple inheritance in C++ with a simple structure called interface, and also has eliminated the use of pointers.
The reason that why Java is much simpler than C++ is because Java uses automatic memory allocation and garbage collection where else C++ requires the programmer to allocate memory and to collect garbage. Also, the number of language constructs in Java is small for such a powerful language. The clean syntax makes Java programs easy to write and read.
Java is Object-oriented programming models the real world. Everything in the world can be modelled as an object. For example, a circle is an object, a person is an object, and a window's icon is an object. Even a mortgage can be perceived as an object. Java is object-oriented because programming in Java is cantered on creating objects, manipulating objects, and making objects work together.
An object has properties and behaviours. Properties are described by using data, and behaviour is described by using methods. Objects are defined by using classes in Java. A class is like a template for the objects.
An object is a concrete realization of a class description. The process of creating an object class is called instantiation. Java consists of one or more classes that are arranged in a treelike hierarchy, so that a child class is able to inherit properties and behaviours from its parent class. An extensive set of pre-defined classes, grouped in packages that can be used in programs are found in Java.
Object-oriented programming provides greater flexibility, modularity and reusability. Java has helped object-oriented technology enter the mainstream of computing, with its simple and clean structure that allows the programmer to write easy to read and write programs.
Distributed Computing
Java Distributed Computing offers a general introduction to distributed computing, meaning programs that run on two or more systems. It focuses primarily on how to structure and write distributed applications and discusses issues like designing protocols, security, working with databases, and dealing with low bandwidth situations
Distributed computing and Java go together naturally. As the first language designed from the bottom up with networking in mind, Java makes it very easy for computers to cooperate. Even the simplest applet running in a browser is a distributed application, if you think about it. The client running the browser downloads and executes code that is delivered by some other system. But even this simple applet wouldn't be possible without Java's guarantees of portability and security: the applet can run on any platform, and can't sabotage its host.
Of course, when we think of distributed computing, we usually think of applications more complex than a client and server communicating with the same protocol. We usually think in terms of programs that make remote procedure calls, access remote databases, and collaborate with others to produce a single result. Java Distributed Computing discusses how to design and write such applications. It covers Java's RMI (Remote Method Invocation) facility and CORBA, but it doesn't stop there; it tells you how to design your own protocols to build message passing systems and discusses how to use Java's security facilities, how to write multithreaded servers, and more. It pays special attention to distributed data systems, collaboration, and applications that have high bandwidth requirements.
Security
Java is one of the first programming languages to consider security as part of its design. The Java language, compiler, interpreter, and runtime environment were each developed with security in mind. The compiler, interpreter, and Java-compatible browsers all contain several levels of security measures that are designed to reduce the risk of security compromise, loss of data and program integrity, and damage to system users. Considering the enormous security problems associated with executing potentially untrusted code in a secure manner and across multiple execution environments, Java's security measures are far ahead of even those developed to secure military systems. C and C++ do not have any intrinsic security capabilities.
Multimedia: Images, Sounds and Animation
The sizzle of JAVA is MULTIMEDIA - Sounds, Images, Graphics and Video. In this growing age of multimedia, new computers are known as "multimedia ready" with CD-Rom drives, sound cards, 3D accelerator cards and other new special sound or graphic technology capabilities. Programming languages that make creating multimedia easy. Most programming languages do not have built-in multimedia capabilities. JAVA, however through the packages of classes that are an integral part of the Java programming world, provides extensive multimedia facilities that will enable a programmer to start developing powerful multimedia applications immediately. Among the image formats supported by Java is the Graphics Interchange Format .GIF and Joint Photography Experts Group .JPEG. Among the audio formats are AIFF, AU and WAV. Music formats currently supported are MIDI Type 0, MIDI Type 1, and Rich Music Format (RMF). Sound formats now allow 8- and 16-bit audio data, in mono and stereo, with sample rates from 8 kHz to 48 kHz. Capability to play MPEG- Layer 2 and 3 formats are also available. And the list goes on, and continues to grow.
Robust
Robust means reliable and no programming language can really assure reliability. Java puts a lot of emphasis on early checking for possible errors, as Java compilers are able to detect many problems that would first show up during execution time in other languages. Java eliminates certain types of programming constructs in other languages that are prone to errors. For instance, Java does not support pointers, which eliminates the possibility of overwriting memory and corrupting data. Java has a runtime exception-handling feature to provide programming support for robustness, and can catch and respond to an exceptional situation so that the program can continue its normal execution and terminate gracefully when a runtime error occurs.
Portable
One advantage of Java is that its programs can run on any platform without having to be recompiled. This is one positive aspect of portability. It goes on even further to ensure that there are no platform-specific features on the Java language specification. For example, in some languages, such as Ada, the largest integer varies on different platforms. In Java, the size of the integer is the same on every platform, as is the behaviour of arithmetic. Having a fixed size for numbers makes Java programs portable. The Java environment itself is portable to new hardware and operating systems, and in fact, the Java compiler itself is written in Java.
Project Life Cycle:
Project Initiation Phase
The Project Initiation Phase includes the activities required to initiate a project. This includes the creation of a Business Case, the undertaking of a Feasibility Study and documentation of a Terms of Reference. It also includes the identification of the project scope, the appointment of the project team and the establishment of the project office, as depicted by the following diagram.
See our Project Initiation templates, helping you to initiate projects more efficiently than before. By using these templates, you will be able to quickly perform initiation activities such as building a business case and undertake feasibility studies. Using such documents as the business case template, you will be able to apply a standard business case format to all documents created within your project.
Project Planning Phase
The Project Planning Phase involves the creation of project plans including a Project Plan, Financial Plan, Quality Plan, Resource Plan and Risk Plan. These plans are created to ensure that all project phases, activities and tasks have been clearly identified and adequate resources and finances have been allocated, before the project execution begins. A preferred supplier may be selected to undertake certain project activities and to supply product to the project, as depicted by the following diagram.
See our Project planning templates, helping you to plan projects more efficiently than before. By using these templates, you will be able to perform project planning, quality planning, resource planning and risk planning for each project undertaken.
Project Execution Phase
This phase involves the execution of each activity and task listed in the Project Plan. While the activities and tasks are being executed, a series of project management processes are undertaken to monitor and control the deliverables being produced by the project. These project management processes include the monitoring and control of project time, costs, quality, changes, risks, issues, procurement, customer acceptance and communications, as depicted by the following diagram:
Change Management Processes help you to manage project scope, by monitoring and controlling changes identified
Risk Management Processes will help you to mitigate risk, by identifying and implementing risk mitigating actions
Project Closure Phase
Project Closure, otherwise known as 'Project Close Out', involves releasing the final deliverables to the customer, handing over project documentation, terminating supplier contracts, releasing project resources and communicating the closure of the project to all stakeholders. The last remaining step is to undertake a Post Implementation Review (i.e. a post project review) to quantify the overall success of the project and list any lessons learnt in a formal report for future projects.
Role Played by the Project
The program for this project was developed using which is simple, Reliability for which Java is one of the first programming languages to consider security as part of its design. The Java language, compiler, interpreter, and runtime environment were each developed with security in mind. The compiler, interpreter, and Java-compatible browsers all contain several levels of security measures that are designed to reduce the risk of security compromise, loss of data and program integrity, and damage to system users. Considering the enormous security problems associated with executing potentially untrusted code in a secure manner and across multiple execution environments, Java's security measures are far ahead of even those developed to secure military systems.
The program will first display the following
Book title:- this means the user should enter a valid book title choosing from the catalogue
Book quantity: - this means the user should enter the quantity of book sold if any must be specify
Book author:- this means the user must enter the author of the book if he/she are researching for any specific book
Book publisher:- this means the user must enter the publisher’s name for ordering or any books
Book price:- this means the prize of the book must be given
Future of the project:
This project can be enhanced with extra futures such as Internet book ordering using websites, which can increase the future of the BOOKS bookstore.
Increase the catalogue of books selection that may include fiction, crime and other interest of the people.
Increase the features of the project with oracle database connecting using java script and java applets
Code:
//Program for a bookstore Inventory
import java.io.*;
public class BookInventory
{
String bookTitle[] = {"Jungle book","Marketing","Spider man","Super man"};
String quantity[] = {"200","310","250","500"};
String author[] = {"Sinclair","Prof Richard","Stan lee","Dr. Johnson"};
String publisher[] = {"Ben Press","PC World","Press Rev's","Rev's Press"};
String price[] = {"16","65","25","50"};
String name;
int j;
boolean done = false;
InputStreamReader input;
BufferedReader br;
public BookInventory() throws IOException
{
input = new InputStreamReader(System.in);
br = new BufferedReader(input);
System.out.println("\n\t\t*******************************");
System.out.println("\t\t| Welcome to RAve books |");
System.out.println("\n\t\t| Inventory store. |");
System.out.println("\n\t\t| Please choose one of the |");
System.out.println("\n\t\t| options below: |");
System.out.println("\t\t*******************************");
callOptions();
}
public void callOptions() throws IOException
{
System.out.println("\n1. View all Books!");
System.out.println("2. Find a book!");
System.out.println("3. Purchase a book!");
System.out.println("4. Exit from the program");
System.out.print("\n\tPlease select only one option:\t");
String readLine = br.readLine();
int read = Integer.parseInt( readLine );
if(read == 1)
{
getAllBooks();
}
else if(read == 2)
{
getOneBook();
}
else if(read == 3)
{
getPurchaseABook();
}
else if(read == 4)
{
System.out.println("\nProgram exited");
System.exit(0);
}
else
{
System.out.println("\nPlease select only from the options above");
callOptions();
}
}
public void getAllBooks() throws IOException
{
System.out.println("\nBook Title Author Publisher Quantity Price");
System.out.println("================================================================================");
System.out.println(bookTitle[0]+" "+author[0]+" "+publisher[0]+" "+quantity[0]+" "+price[0]);
System.out.println(bookTitle[1]+" "+author[1]+" "+publisher[1]+" "+quantity[1]+" "+price[1]);
System.out.println(bookTitle[2]+" "+author[2]+" "+publisher[2]+" "+quantity[2]+" "+price[2]);
System.out.println(bookTitle[3]+" "+author[3]+" "+publisher[3]+" "+quantity[3]+" "+price[3]);
callOptions();
}
public void getOneBook() throws IOException
{
System.out.print("\nEnter the name of a Book:\t");
String name = br.readLine();
for(int i=0;i<bookTitle.length;i++)
{
if(name.equalsIgnoreCase(bookTitle[i]))
{
done = true;
if(bookTitle[i] == "Jungle book")
{
System.out.println("\nBook Title Author Publisher Quantity Price");
System.out.println("================================================================================");
System.out.println(bookTitle[i]+" "+author[i]+" "+publisher[i]+" "+quantity[i]+" "+price[i]);
}
else if(bookTitle[i] == "Marketing")
{
System.out.println("\nBook Title Author Publisher Quantity Price");
System.out.println("================================================================================");
System.out.println(bookTitle[i]+" "+author[i]+" "+publisher[i]+" "+quantity[i]+" "+price[i]);
}
else if(bookTitle[i] == "Spider man")
{
System.out.println("\nBook Title Author Publisher Quantity Price");
System.out.println("================================================================================");
System.out.println(bookTitle[i]+" "+author[i]+" "+publisher[i]+" "+quantity[i]+" "+price[i]);
}
else if(bookTitle[i] == "Super Man")
{
System.out.println("\nBook Title Author Publisher Quantity Price");
System.out.println("================================================================================");
System.out.println(bookTitle[i]+" "+author[i]+" "+publisher[i]+" " +quantity[i]+" "+price[i]);
}
}
}
if(done == false)
{
System.out.println("\nBook not found:\t");
}
callOptions();
}
public void getPurchaseABook() throws IOException
{
System.out.print("\nEnter the name of the Book:\t\t");
String name = br.readLine();
for(int i=0;i<bookTitle.length;i++)
{
if(name.equalsIgnoreCase(bookTitle[i]))
{
done = true;
System.out.print("What is the quantity you require?\t");
String acc = br.readLine();
int readAcc = Integer.parseInt(acc);
int prices = Integer.parseInt(price[i]);
double totalPrice = readAcc*prices;
String total = String.valueOf(totalPrice);
int realQuantity = Integer.parseInt(quantity[i]);
int quantities = realQuantity - readAcc;
String quant = String.valueOf(quantities);
System.out.println("\nYour purchase details are as follows:");
System.out.println("\nBook Title\t\t"+bookTitle[i]);
System.out.println("Author\t\t\t"+author[i]);
System.out.println("Publisher\t\t"+publisher[i]);
System.out.println("Quantity required\t"+readAcc);
System.out.println("Unit price\t\t"+price[i]);
System.out.println("Total Price\t\t"+total);
System.out.print("\nPurchase this book? (Y for yes / N for no)\t" );
String getIt = br.readLine();
if(getIt.equalsIgnoreCase("y") )
{
quantity[i] = quant;
System.out.println("\nThank You For Your Visit. Hope to see you soon again!");
}
else
System.out.println("\nYou have selected No to stop the transaction. Thanks !");
}
}
if(done == false)
{
System.out.println("\nBook not found:\t");
}
callOptions();
}
public static void main(String args[])throws IOException
{
BookInventory obj = new BookInventory();
}
}
Conclusion
The purpose of this program is to maintain the inventory of books that are been sold at Rave`s BOOK`s book shop. This program is developed by uisng Java which is a platform independent language. The java language supports security, relaibility, which is important to develop this program. The function of this program are searching of books, inputting the title and author on the system, displays the book details and the request of number of copies required and display the total cost of copies.