HND-OOP assignment

February 2, 2017 | Author: Sandhya Paudel | Category: N/A
Share Embed Donate


Short Description

Download HND-OOP assignment...

Description

HND (HIGHER NATIONAL DIPLOMA)

Object Oriented Programming Assignment 1 Rajendra Paudel Queensland College Dec 2010

1

Acknowledgement

First and foremost, I would like to express my gratitude to my lecturer of this assignment, Mrs. Prerna Kanwar for the valuable suggestions, guidance and advice. She inspired and motivates me greatly to complete this assignment. I also would like to thank him for showing me some example that related to the topic of my assignment. Besides, I would like to thank the authority of Queensland College for providing me with a good environment and facilities to complete this assignment. In addition, I would also like to thank all of my friends who provide me valuable information as the guidance of my assignment. Finally, an honourable mention goes to my wife Mrs Sandhya Paudel for her help, understandings and supports on me in research and completing this assignment.

2

Table of Contents

Content

Page No

Introduction

4

Procedural Programming Language

4

Object Oriented Programming

5

CRC Design Method

10

Class Diagram

13

CRC using Java Structure

15

Requirement for JAVA

18

Role of Class Library in Java

22

Abstract Windowing Toolkit (AWT)

22

Java Applet

22

References

25

3

Introduction

The West London College is a newly opened FE college with 200students and 20 Lectures. The college recruits both part time and fulltime students. The College wants to record all the student’s personnel information like their name, address, contact number, email address during the time of the registration and assigned a unique Student ID number for each student who can only enrol in one course as full time or part time student and has to pay their course fees during enrolment either full or instalments basis. Besides this college wants to record information for lecturers and assigned a unique ID for them and they must teach one or more module, which has its own code, name and information. A course is identified by its unique ID number, which assigned start date and end date and is usually delivered over three working days of the week and has many modules. Any programming languages may implement to design a program for West London College and can solve a problem. Any problem that can be solved using one programming language may also be solved using any other programming language. However, there will be huge variations in the sizes of these programs, how much it cost, how long it take to develop, how reliably accurate they are, and in their execution speeds. Among the programming language a Procedural Language Programming or Object Oriented Programming can be used for College. Procedural Programming Language: Procedural language, a term used in contrast to declarative language, describes a language where the programmer specifies an explicit sequences of steps to follow to produce a result. Common procedural languages include Basic, Pascal, C and Modula-2. In a procedural-based programming language, a programmer writes out instructions that are followed by a computer from start to finish, which is also called a Top Down Design. This starts with a problem and then systematically breaks the problem down into sub problems called functional decomposition, which continues until a sub problem is straightforward enough to be solved by the corresponding sub procedure.

4

Advantages of Procedural Programming •

Its relative simplicity, and ease of implementation of compilers and interpreters



The ability to re-use the same code at different places in the program without copying it.



An easier way to keep track of program flow.



The ability to be strongly modular or structured.



Needs only less memory.

Limitation of Procedural Language •

Procedural programming tends to be relatively low level compared to some other paradigms, and as a result can be very much less productive. .



The software maintenance can be difficult and time consuming.



When changes are made to the main procedure, the change may impact all procedures in the pyramid



Difficult to identify the errors.



If any modifications are there in the code it is difficult to modify.



Less flexible

Object Oriented Programming SIMULA was the first object language. As its name suggests it was used to create simulations. The idea of object-oriented programming gained momentum in the 1970s and in the early 1980s Bjorn Stroustrup integrated object-oriented programming into the C language. The resulting language was called C++ and it became the first objectoriented language to be widely used commercially.In the early 1990s a group at Sun led by James Gosling developed a simpler version of C++ called Java that was meant to be a programming language for video-on-demand applications.. Object-oriented programming is a programming paradigm that uses abstraction (in the form of classes and objects) to create models based on the real world environment. An object-oriented application uses a collection of objects, which communicate by passing messages to request services. Objects are capable of passing messages, receiving messages, and processing data. The aim of object-oriented programming is to try to increase the flexibility and maintainability of programs. Because programs created using an OO language are modular, they can be easier to develop, and simpler to understand after development.

5

The following statement defines an object oriented programming language: Object-oriented language = Object-based features + Inheritance + Polymorphism Concepts of OOP •

Objects



Classes



Data Abstraction and Encapsulation



Inheritance



Polymorphism

Objects Objects are the basic run-time entities in an object-oriented system. Programming problem is analyzed in terms of objects and nature of communication between them. When a program is executed, objects interact with each other by sending messages. Different objects can also interact with each other without knowing the details of their data or code.

Classes A class is a collection of objects of similar type. Once a class is defined, any number of objects can be created which belong to that class.

Data Abstraction and Encapsulation Abstraction refers to the act of representing essential features without including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes. Storing data and functions in a single unit (class) is encapsulation. Data cannot be accessible to the outside world and only those functions which are stored in the class can access it.

6

Inheritance Inheritance is the process by which objects can acquire the properties of objects of other class. In OOP, inheritance provides reusability, like, adding additional features to an existing class without modifying it. This is achieved by deriving a new class from the existing one. The new class will have combined features of both the classes.

Polymorphism Polymorphism means the ability to take more than one form. An operation may exhibit different behaviours in different instances. The behaviour depends on the data types used in the operation. Polymorphism is extensively used in implementing Inheritance.[1] The biggest advantage of polymorphism is creation of reusable code by programmers, classes once written, tested and implemented can be easily reused without caring about what’s written in the cases. Student

Full time Student

Part time Student

Figure.1

In above fig.1 whatever code is written for student , can be used by full time student or part time student and if the West London College in given scenario need another student subclass. For eg. Student WLC = new student ( ); Student WLC = new Full time Student ( ); Student WLC = new Part time Student ( ); Student WLC = new ……….. Student ( );

7

Advantages of Object-Oriented Programming •

Analysis and Design Made Easier



Code Reuse



Ease of Maintenance and Enhancement



Iterations Fewer and Shorter



Software reuse is enhanced.



Software maintenance cost can be reduced.



Data access is restricted providing better data security.



Software is easily developed for complex problems.



Software may be developed meeting the requirements on time, on the estimated budget.



Class hierarchies are helpful in the design process allowing increased extensibility.



Modularity is achieved.



Data abstraction is possible.

Limitations of Object-Oriented Programming •

OOP is a high level concepts so takes more time to execute as many routines run behind at the time of execution.



Offers less number of functions as compared to low level programming which interacts directly with hardware.



Increased burden on part of OOP developer.



Solving a problem using OOP approach consumes more time than the time taken by Structured programming approach.

Conclusion: There are advantages as well as disadvantages to using either structured programming languages or object-oriented languages when developing an application. In comparison, object-oriented languages often contain a set of reusable modular components, which can be called to execute at various points throughout the program, without rewriting them. The object-oriented programming languages is modular so it’s possible to use reusable piece of code like class and a function. These can be use multiple times throughout a programme without rewrite them which can save developer time and efforts but in structure language code is not split up in to reusable

8

so the code is written and executed sequentially which could have cause redundant code and may take longer time to develop a programme. Normally we can compare two programming language as follows. Structured Programming Language

Object Oriented Programming Language

1) Data and Functions don’t tide with each other.

1) Functions and data are tide together. 2) Programs are divided into entity called Objects.

2) Large programs are divided into smaller self contained program segment known as functions

3) Data is hidden and can’t be accessed by the external world

3) Data moves openly around the system from function to function.

4) Functions are not dependent so reusability is possible

4) Functions are dependent reusability is not possible

5) Focus is given to the data rather than procedure.

so

5) Stress is on the algorithms used to solve the problem. Data takes the back seat.

6) Data is compartmentalized capsules or objects.

into

7) Decides the classes and objects required and provides full set of operations for each class.

6) Algorithm for solving the problem is compartmentalized into modules or functions.

8) It is centered on the concepts of objects, data abstraction, encapsulation, inheritance and polymorphism.

7) Uses the best algorithm from among the different procedures available. 8) It has reduced data security and data integrity, as they are globally accessible to all the functions.

Data security is more in object oriented algorithm due to private data type as compare to procedure programming approach. Structured programming language is a simply a collection of functions but do not have more security. In object oriented programming there

is

more

secure

through

using exception

handling,

encapsulation

and data hiding using its access specifies. Considering this above mention points OOP is recommended to use to develop a programme for the West London College.

9

CRC Design Method Student Student-ID

Payment

Name

Course

Date of Birth

Lecture

Address Contact No E-mail ID Enrolled Course Detail Payment History Allocated Tutor Detail Add Student Delete Student Edit Student Search Student Display Student Info Print Student Info

Course Course-ID

Module

Start Date End Date Has Module Details Types of Course Cost of Course Days Delivered Edit Course Add Course Delete course Search Course View Course Print Course

10

Lecturer Lecturer_ID

Module

Name

Student

DOB Address Contact No E-mail ID Qualification Visa Status Assigned Course Assigned Student Add Lecturer Info Delete Lecturer Info Edit Lecturer Info Search Lecturer Info Display Lecturer Info Print Lecturer Info

Module Module Code

Lecturer

Name Description Assigned Lecturer Add Module Delete Module Edit module Search Module Display Module Info Print module Info

11

Payment Amount Paid

Student

Due Amount Mode of Payment Date of Payment Paid By Add New Payment Edit Payment Info Display Payment Info Print Payment Info

12

0...M

Student

0...1

Class Diagram

Lecturer

Student-ID

Lecturer_ID

Name

Name

Date of Birth

DOB

Course

Address

Address

Course-ID

Enrolled Course Detail

Start Date

Payment History

End Date

Allocated Tutor Detail

Has Module Details

Add Student

0...M

1...1M

Contact No E-mail ID

Cost of Course

Edit Student

Days Delivered

Search Student

Edit Course

1...1

Visa Status

Types of Course

Delete Student

Display Student Info

Qualification Assigned Course Assigned Student Add Lecturer Info Delete Lecturer Info

Add Course

Print Student Info

Edit Lecturer Info

Delete course

Search Lecturer Info

Search Course

Display Lecturer Info

View Course Full Time Student

Part Time Student

Student-ID

Student-ID

Name

Name

Date of Birth

Date of Birth

Address

Address

Enrolled Course Detail

Enrolled Course Detail

Payment History

Payment History

Allocated Tutor Detail

Allocated Tutor Detail

Add Student

Add Student

Delete Student

Delete Student

Edit Student

Edit Student

Search Student

Search Student

Display Student Info

Display Student Info

Print Student Info

Print Student Info

Print Lecturer Info

Print Course

1...M

1...M

1...M Module

Payment

Module Code

Amount Paid Due Amount Mode of Payment Date of Payment Paid By Add New Payment Edit Payment Info Display Payment Info Print Payment Info 13

1...M

Name Description Assigned Lecturer Add Module Delete Module Edit module Search Module Display Module Info Print module Info

1...M

HND (HIGHER NATIONAL DIPLOMA)

Object Oriented Programming Assignment 2 Rajendra Paudel Queensland College Dec 2010

14

CRC using Java Structure Student Class: Class Student { int Student_ID [ ] = new int [5]; String Name [ ] = new String [5]; int DOB [ ] = new int [5]; String Address [ ] = new String [5]; int Contact No [ ] = new int [5]; String enrolled course detail [ ] = new String [5]; String payment history [ ] = new String [5]; String allocated tutor detail [ ] = new String [5]; void add Student ( ); void delete Student ( ); void edit Student ( ); void search Student ( ); void display Student Info( ); void print student Info( ); } Lecturer Class: Class Lecturer { int Lecturer_ID [ ] = new int [5]; String Name [ ] = new String [5]; int DOB [ ] = new int [5]; String Address [ ] = new String [5]; int Contact No [ ] = new int [5]; String E-mail ID [ ] = new String [5]; String Qualification [ ] = new String [5]; String Visa Status [ ] = new String [5]; String Assigned Course [ ] = new String [5]; String Assigned Student [ ] = new String [5];

15

void Add Lecturer Info ( ); void Delete Lecturer Info ( ); void Edit Lecturer Info ( ); void Search Lecturer Info ( ); void Display Lecturer Info ( ); void Print Lecturer Info ( ); } Course Class: Class Course { int Course-ID [ ] = new int [5]; String Start Date [ ] = new String [5]; String End Date [ ] = new String [5]; String Has Module Details [ ] = new String [5]; String Types of Course [ ] = new String [5]; int Cost of Course [ ] = new int [5]; int Days Delivered [ ] = new int [5]; void Edit Course ( ); void Add Course ( ); void Delete course ( ); void Search Course ( ); void View Course ( ); void Print Course ( ); } Module Class Class Module { String Module Code [ ] = new String [5]; String Name [ ] = new String [5]; String Description [ ] = new String [5]; String Assigned Lecturer [ ] = new String [5]; 16

void Add Module ( ); void Delete Module ( ); void Edit module ( ); void Search Module ( ); void Display Module Info ( ); void Print module Info ( ); } Payment Class: Class Payment { int Amount Paid [ ] = new int [5]; int Due Amount [ ] = new int [5]; String Mode of Payment [ ] = new String [5]; int Date of Payment [ ] = new int [5]; String Paid By [ ] = new String [5]; void Add New Payment ( ); void Edit Payment Info ( ); void Display Payment Info ( ); void Print Payment Info ( ); }

17

Requirement for JAVA Java is a computer programming language expressly designed for use in the distributed environment of the Internet. Java can be used to create complete applications that may run on a single computer or be distributed among servers and clients in a network. It can also be used to build a small application module or applet for use as part of a Web page. To run the Java user need JDK and JRC. JDK A software development package that implements the basic set of tools needed to write, test and debug Java applications and applets. Typically, each JDK contains one (or more) JRE's along with the various development tools like the Java source compilers, bundling and deployment tools, debuggers, development libraries, etc. JRC The "JRE" is the Java Runtime Environment. JRE is an implementation of the Java Virtual Machine which actually executes Java Programs.

Hardware and Software requirement Intel and 100% compatible processors are supported for java installation. A Pentium 166MHz or faster processor with at least 64MB of physical RAM is recommended. It will also need a minimum of 98MB of free disk space.

18

Windows System Requirements [2]

Platform

Windows x86

Windows x64 32-bit mode

Windows-32 Bit Memory Browser Chrome 4.0, IE 8, Windows 7 128mb Firefox 2, Firefox 3.0.x, Firefox 3.5.x, or Firefox 3.6 Chrome 4.0, IE 7 or IE 8 Windows Vista 128mb Firefox 2, Firefox 3.0.x, Firefox 3.5.x, or Firefox 3.6 IE 7 or IE 8, Firefox 2, Windows 128mb Firefox 3.0.x, Firefox 3.5.x, Server 2008 or Firefox 3.6 Chrome 4.0, IE 6 SP1, IE 7 or IE 8, Firefox 2, Firefox Windows XP 64mb 3.0.x, Firefox 3.5.x, or Firefox 3.6 IE 5.5 or IE 6, Mozilla 1.4, Windows 2000 64mb Mozilla 1.7, Firefox 2 IE 7 or IE 8, Firefox 2, Windows 128mb Firefox 3.0.x, Firefox 3.5.x, Server 2003 or Firefox 3.6 Chrome 4.0, IE 8 Windows 7 128mb Firefox 2, Firefox 3.0.x, Firefox 3.5.x, or Firefox 3.6 Chrome 4.0, IE 7 or IE 8 Windows Vista 128mb Firefox 2, Firefox 3.0.x, Firefox 3.5.x, or Firefox 3.6 IE 7 or IE 8, Firefox 2, Windows 128mb Firefox 3.0.x, Firefox 3.5.x, Server 2008 or Firefox 3.6 Chrome 4.0, IE 6 SP1, IE 7 or IE 8, Firefox 2, Firefox Windows XP 64mb 3.0.x, Firefox 3.5.x, or Firefox 3.6 IE 5.5 or IE 6, Mozilla 1.4, Windows 2000 64mb Mozilla 1.7, Firefox 2 IE 7 or IE 8, Firefox 2, Windows 128mb Firefox 3.0.x, Firefox 3.5.x, Server 2003 or Firefox 3.6 Version

19

Diskspace

98MB

98MB

Platform

Version

Windows (64-bit) Memory Browsers

Windows 7

Windows x64 64-bit mode

Windows Server 2008 Windows Vista

128 MB

Windows XP

Disk Space

64-bit OS, 32-bit Browsers: Chrome 4.0, Firefox 2, Firefox 3.0.x, Firefox 3.5.x, or Firefox 3.6 64-bit OS, 64-bit Browsers: IE 8 64-bit OS, 32-bit Browsers: Firefox 2, Firefox 3.0.x, Firefox 3.5.x, or Firefox 3.6 64-bit OS, 64-bit Browsers: IE 8 64-bit OS, 32-bit Browsers: Chrome 4.0, IE 6 SP1, IE 7, or IE 8, Mozilla 1.4.X or 1.7, Netscape 7.x, Firefox 1.06 3.0.x, Firefox 3.5.x, or Firefox 3.6

98 MB

64-bit OS, 64-bit Browsers: IE 7 or IE 8 64-bit OS, 32-bit Browsers: IE 6 SP1, IE 7, or IE 8, Mozilla 1.4.X or 1.7, Netscape 7.x, Firefox 1.06 - 3.0.x, Firefox 3.5.x, or Firefox 3.6

Windows 2003, Standard Edition (R2, SP1, SP2)

64-bit OS, 64-bit Browsers: IE 7 or IE 8

Linux System Requirements Platform

Linux x86

Versions Oracle Enterprise Linux 5.5, 5.4 Red Hat Enterprise Linux 5.3, 5.4, 5.5

Linux 32-bit Memory

64mb

SUSE 10 SLES 11

20

Browsers Firefox 3.0.x, Firefox 3.5.x, or Firefox 3.6 Firefox 3.0.x, Firefox 3.5.x, or Firefox 3.6 Firefox 2.0.x Firefox 3.0.6, Firefox 3.0.8

Disk Space

58 MB

Platform

Linux x64 64-bit mode

Versions Oracle Enterprise Linux 5.5, 5.4 Red Hat Enterprise Linux 5.3, 5.4, 5.5 Red Hat Enterprise Linux 5.0 (5.1, 5.2) SUSE 8.2, 9, 9.1, 9.2 SLES 11

SLES 10

Linux 64-bit Memory Browsers 64-bit OS, 32-bit Browsers: Firefox 3.0.x, Firefox 3.5.x, or Firefox 3.6 64-bit OS, 32-bit 64mb Browsers: Firefox 3.0.x, Firefox 3.5.x, or Firefox 3.6 64-bit OS, 32-bit Browsers: Firefox 3.0.x, Firefox 3.0.x, 64-bit OS, 32-bit Browsers: Mozilla 1.4 64-bit OS, 32-bit Browsers: Firefox 3.0.6 or 3.0.8 64-bit OS, 32-bit Browsers: Firefox 2.0.x

21

Disk Space

58 MB

Role of Class Library in Java Object oriented programming languages define all of their functionality in terms of objects. All objects of the same type make up a class of objects which have common functionality and it is coded into the program as a class which can called as a collection of prewritten, ready-made software routines that act as templates for programmers to use in writing programs. The greatest benefits are primarily for application extensibility code re-usability and program stability. Access to and use of a class library greatly simplifies the job of the programmer since standard, pretested code is available that the programmer doesn't have to write. The class libraries provide an abstract interface to tasks that would normally depend heavily on the hardware and operating system. Why use Class Library? •

By reusing functions from Java's huge class library, software can be implemented faster and with fewer errors.



The abstraction provided by the Java class library is cleaner, which makes them easier to understand and use.



Standard, pretested code is available that the programmer doesn't have to write any code.



Graphic



Error maintain

Abstract Windowing Toolkit (AWT) Window Toolkit (AWT) is a set of application program interfaces ( API s) used by Java programmers to create graphical user interface ( GUI ) objects, such as buttons, scroll bars, and windows for applets and standalone applications. Java Applet Java applet gives the interactive web development. An applet is a special kind of Java program that a browser enabled with Java technology can download from the internet and run. An applet is typically embedded inside a web page and runs in the context of a browser. An applet must be a subclass of the java.applet.Applet class. 22

Sample Programme import java.awt.*; import java.applet.*; public class GuiExample extends Applet { Button okButton; TextField nameField; CheckboxGroup radioGroup; Checkbox radio1; Checkbox radio2; Checkbox option;

public void init() { SetLayout(null); okButton = new Button("First button"); nameField = new TextField("First TextField",100); radioGroup = new CheckboxGroup(); radio1 = new Checkbox("Radio1", radioGroup,false); radio2 = new Checkbox("Radio2", radioGroup,true); option = new Checkbox("Option",false); okButton.setBounds(20,20,100,30);

23

nameField.setBounds(20,70,100,40); radio1.setBounds(20,120,100,30); radio2.setBounds(140,120,100,30); option.setBounds(20,170,100,30);

add(okButton); add(nameField); add(radio1); add(radio2); add(option); } }

24

References

http://wiki.tcl.tk/13398 [Accessed 15 Nov 2010] http://www.java.com/en/download/help/sysreq.xml [Accessed 26 Nov 2010]

25

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF