HND-OOP assignment



Comments



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 Introduction Procedural Programming Language Object Oriented Programming CRC Design Method Class Diagram CRC using Java Structure Requirement for JAVA Role of Class Library in Java Abstract Windowing Toolkit (AWT) Java Applet References Page No 4 4 5 10 13 15 18 22 22 22 25 3 . a programmer writes out instructions that are followed by a computer from start to finish. 4 . contact number. This starts with a problem and then systematically breaks the problem down into sub problems called functional decomposition.Introduction The West London College is a newly opened FE college with 200students and 20 Lectures. address. A course is identified by its unique ID number. Procedural Programming Language: Procedural language. Among the programming language a Procedural Language Programming or Object Oriented Programming can be used for College. In a procedural-based programming language. Besides this college wants to record information for lecturers and assigned a unique ID for them and they must teach one or more module. describes a language where the programmer specifies an explicit sequences of steps to follow to produce a result. Pascal. how long it take to develop. 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. However. C and Modula-2. Common procedural languages include Basic. how much it cost. Any programming languages may implement to design a program for West London College and can solve a problem. name and information. and in their execution speeds. which continues until a sub problem is straightforward enough to be solved by the corresponding sub procedure. a term used in contrast to declarative language. The college recruits both part time and fulltime students. which assigned start date and end date and is usually delivered over three working days of the week and has many modules. Any problem that can be solved using one programming language may also be solved using any other programming language. which has its own code. The College wants to record all the student’s personnel information like their name. how reliably accurate they are. which is also called a Top Down Design. there will be huge variations in the sizes of these programs. As its name suggests it was used to create simulations. An easier way to keep track of program flow. If any modifications are there in the code it is difficult to modify. 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 object-oriented application uses a collection of objects. The resulting language was called C++ and it became the first objectoriented language to be widely used commercially. they can be easier to develop. 5 . and as a result can be very much less productive. Procedural programming tends to be relatively low level compared to some other paradigms. Less flexible Object Oriented Programming SIMULA was the first object language.. the change may impact all procedures in the pyramid Limitation of Procedural Language • • • Difficult to identify the errors. The aim of object-oriented programming is to try to increase the flexibility and maintainability of programs. and processing data. 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. When changes are made to the main procedure. Needs only less memory. and simpler to understand after development. Objects are capable of passing messages. receiving messages.Advantages of Procedural Programming • • • • • • • • Its relative simplicity. 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. which communicate by passing messages to request services. The software maintenance can be difficult and time consuming. . The ability to be strongly modular or structured. Because programs created using an OO language are modular.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. Data cannot be accessible to the outside world and only those functions which are stored in the class can access it. Classes use the concept of abstraction and are defined as a list of abstract attributes. Programming problem is analyzed in terms of objects and nature of communication between them. any number of objects can be created which belong to that class. Classes A class is a collection of objects of similar type. When a program is executed. Data Abstraction and Encapsulation Abstraction refers to the act of representing essential features without including the background details or explanations. Storing data and functions in a single unit (class) is encapsulation. 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. Once a class is defined.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. 6 . In OOP. Student WLC = new ………. The behaviour depends on the data types used in the operation. tested and implemented can be easily reused without caring about what’s written in the cases. can be used by full time student or part time student and if the West London College in given scenario need another student subclass. Student ( ). Student WLC = new Part time Student ( ). adding additional features to an existing class without modifying it. Student WLC = new student ( ).. Polymorphism is extensively used in implementing Inheritance. Student Full time Student Part time Student Figure. Student WLC = new Full time Student ( ).Inheritance Inheritance is the process by which objects can acquire the properties of objects of other class. This is achieved by deriving a new class from the existing one. classes once written. The new class will have combined features of both the classes. inheritance provides reusability.1 In above fig. An operation may exhibit different behaviours in different instances. For eg. 7 .[1] The biggest advantage of polymorphism is creation of reusable code by programmers. like. Polymorphism Polymorphism means the ability to take more than one form.1 whatever code is written for student . object-oriented languages often contain a set of reusable modular components. Offers less number of functions as compared to low level programming which interacts directly with hardware. Increased burden on part of OOP developer. 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. on the estimated budget. Software is easily developed for complex problems. 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 . Data abstraction is possible. The object-oriented programming languages is modular so it’s possible to use reusable piece of code like class and a function. Modularity is achieved. without rewriting them. In comparison.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. Solving a problem using OOP approach consumes more time than the time taken by Structured programming approach. Class hierarchies are helpful in the design process allowing increased extensibility. Conclusion: There are advantages as well as disadvantages to using either structured programming languages or object-oriented languages when developing an application. Software may be developed meeting the requirements on time. which can be called to execute at various points throughout the program. Software maintenance cost can be reduced. Data access is restricted providing better data security. 8) It has reduced data security and data integrity. Data takes the back seat. 2) Large programs are divided into smaller self contained program segment known as functions 3) Data moves openly around the system from function to function. Normally we can compare two programming language as follows. In object oriented programming there is more secure through using exception handling. 2) Programs are divided into entity called Objects. Structured programming language is a simply a collection of functions but do not have more security. 7) Uses the best algorithm from among the different procedures available. Considering this above mention points OOP is recommended to use to develop a programme for the West London College. 4) Functions are dependent reusability is not possible so Object Oriented Programming Language 1) Functions and data are tide together. 8) It is centered on the concepts of objects. 3) Data is hidden and can’t be accessed by the external world 4) Functions are not dependent so reusability is possible 5) Focus is given to the data rather than procedure. Structured Programming Language 1) Data and Functions don’t tide with each other. as they are globally accessible to all the functions. 9 . Data security is more in object oriented algorithm due to private data type as compare to procedure programming approach.so the code is written and executed sequentially which could have cause redundant code and may take longer time to develop a programme. inheritance and polymorphism. 7) Decides the classes and objects required and provides full set of operations for each class. encapsulation. 6) Data is compartmentalized capsules or objects. into 5) Stress is on the algorithms used to solve the problem. 6) Algorithm for solving the problem is compartmentalized into modules or functions. data abstraction. encapsulation and data hiding using its access specifies. CRC Design Method Student Student-ID Name Date of Birth 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 Payment Course Lecture Course Course-ID 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 Module 10 . Lecturer Lecturer_ID Name 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 Student Module Module Code Name Description Assigned Lecturer Add Module Delete Module Edit module Search Module Display Module Info Print module Info Lecturer 11 . Payment Amount Paid Due Amount Mode of Payment Date of Payment Paid By Add New Payment Edit Payment Info Display Payment Info Print Payment Info Student 12 . ..M 1.M 1.M Module Module Code Name Description Assigned Lecturer Add Module Delete Module Edit module Search Module Display Module Info Print module Info 1.Student Student-ID Name Date of Birth Address Enrolled Course Detail Payment History Allocated Tutor Detail Add Student Delete Student Edit Student Search Student Display Student Info Print Student Info 0........M Payment 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 1..1M 1....M ...1 Add Course Delete course Search Course View Course Full Time Student Student-ID Name Date of Birth Address Enrolled Course Detail Payment History Allocated Tutor Detail Add Student Delete Student Edit Student Search Student Display Student Info Print Student Info Part Time Student Student-ID Name Date of Birth Address Enrolled Course Detail Payment History Allocated Tutor Detail Add Student Delete Student Edit Student Search Student Display Student Info Print Student Info Print Course 1....1 Name Course DOB Lecturer Lecturer_ID Course-ID Start Date End Date Has Module Details Types of Course Cost of Course Days Delivered Edit Course 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 0..M Class Diagram 0. HND (HIGHER NATIONAL DIPLOMA) Object Oriented Programming Assignment 2 Rajendra Paudel Queensland College Dec 2010 14 . 15 . int DOB [ ] = new int [5]. int Contact No [ ] = new int [5]. int Contact No [ ] = new int [5]. String Name [ ] = new String [5]. void search Student ( ). String Qualification [ ] = new String [5]. int DOB [ ] = new int [5]. void delete Student ( ). } Lecturer Class: Class Lecturer { int Lecturer_ID [ ] = new int [5]. String Assigned Course [ ] = new String [5]. void add Student ( ). void edit Student ( ). String E-mail ID [ ] = new String [5]. String Address [ ] = new String [5]. String enrolled course detail [ ] = new String [5]. String Address [ ] = new String [5]. String Name [ ] = new String [5]. void print student Info( ).CRC using Java Structure Student Class: Class Student { int Student_ID [ ] = new int [5]. String Visa Status [ ] = new String [5]. String allocated tutor detail [ ] = new String [5]. String Assigned Student [ ] = new String [5]. String payment history [ ] = new String [5]. void display Student Info( ). String Assigned Lecturer [ ] = new String [5]. void Delete course ( ). String Description [ ] = new String [5]. void Print Lecturer Info ( ). void Edit Lecturer Info ( ). void Add Course ( ). void Search Course ( ). 16 .void Add Lecturer Info ( ). void Print Course ( ). void View Course ( ). String Types of Course [ ] = new String [5]. void Edit Course ( ). String Start Date [ ] = new String [5]. void Delete Lecturer Info ( ). String Has Module Details [ ] = new String [5]. } Module Class Class Module { String Module Code [ ] = new String [5]. int Cost of Course [ ] = new int [5]. String Name [ ] = new String [5]. String End Date [ ] = new String [5]. void Display Lecturer Info ( ). } Course Class: Class Course { int Course-ID [ ] = new int [5]. int Days Delivered [ ] = new int [5]. void Search Lecturer Info ( ). String Paid By [ ] = new String [5]. void Print module Info ( ).void Add Module ( ). int Due Amount [ ] = new int [5]. void Search Module ( ). void Add New Payment ( ). void Display Module Info ( ). void Edit module ( ). void Print Payment Info ( ). int Date of Payment [ ] = new int [5]. String Mode of Payment [ ] = new String [5]. void Delete Module ( ). } 17 . void Display Payment Info ( ). void Edit Payment Info ( ). } Payment Class: Class Payment { int Amount Paid [ ] = new int [5]. JRE is an implementation of the Java Virtual Machine which actually executes Java Programs. 18 . test and debug Java applications and applets. To run the Java user need JDK and JRC. JDK A software development package that implements the basic set of tools needed to write. bundling and deployment tools. It can also be used to build a small application module or applet for use as part of a Web page. Hardware and Software requirement Intel and 100% compatible processors are supported for java installation. development libraries. Typically. A Pentium 166MHz or faster processor with at least 64MB of physical RAM is recommended. etc. each JDK contains one (or more) JRE's along with the various development tools like the Java source compilers. JRC The "JRE" is the Java Runtime Environment.Requirement for JAVA Java is a computer programming language expressly designed for use in the distributed environment of the Internet. It will also need a minimum of 98MB of free disk space. 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. debuggers. x.5. Server 2003 or Firefox 3.6 IE 5.6 Chrome 4.0.5. IE 7 or IE 8.6 Chrome 4.0.0.5.6 Chrome 4. Firefox 3.x. Server 2008 or Firefox 3.0.6 Chrome 4.6 IE 7 or IE 8. or Firefox 3. Windows 128mb Firefox 3.0.6 IE 5. Firefox 2.x.x.5. Windows 2000 64mb Mozilla 1.5 or IE 6.0. Windows 128mb Firefox 3. Firefox 2 IE 7 or IE 8.x. Firefox 3. Server 2003 or Firefox 3. Firefox 3.0. Firefox 2 IE 7 or IE 8. or Firefox 3. IE 8. Firefox 3.6 IE 7 or IE 8. Firefox Windows XP 64mb 3. Firefox 3. Firefox 2.x.x. IE 7 or IE 8. Windows 7 128mb Firefox 2.x. Windows 128mb Firefox 3. Firefox 3.4.x.0. or Firefox 3.6 Version Platform Diskspace Windows x86 98MB Windows x64 32-bit mode 98MB 19 . Firefox 3. Firefox 2. or Firefox 3.x.0.x.0.7. Mozilla 1.0.0. IE 7 or IE 8 Windows Vista 128mb Firefox 2. IE 6 SP1. Firefox 3. Windows 2000 64mb Mozilla 1. Firefox 3. Server 2008 or Firefox 3.0. Firefox 3. Firefox Windows XP 64mb 3.5. or Firefox 3.x.x.x.0.6 Chrome 4. Mozilla 1. Firefox 3.5.x.x.5.5. Firefox 2.x.4. IE 8 Windows 7 128mb Firefox 2.7. IE 7 or IE 8 Windows Vista 128mb Firefox 2.x. Windows 128mb Firefox 3.x. Firefox 2.x.5.5 or IE 6.Windows System Requirements [2] Windows-32 Bit Memory Browser Chrome 4. Firefox 2. or Firefox 3. IE 6 SP1.5.0. Firefox 3. Firefox 3. Firefox 3.0. x.3.6 64-bit OS. or IE 8. SP1.06 . Firefox 3. Firefox 3. or Firefox 3.8 Disk Space 58 MB Linux x86 64mb 20 .0. 64-bit Browsers: IE 7 or IE 8 64-bit OS.4.5. IE 6 SP1. or Firefox 3.6 64-bit OS. or Firefox 3. or Firefox 3.x. Mozilla 1.5.Platform Version Windows 7 Windows (64-bit) Memory Browsers 64-bit OS.x.7.0.X or 1. SP2) Linux System Requirements Platform Versions Oracle Enterprise Linux 5.4 Red Hat Enterprise Linux 5.6 Firefox 3. Firefox 3. Netscape 7.X or 1.6 64-bit OS.x.x.6 64-bit OS. Firefox 3. or Firefox 3. 64-bit Browsers: IE 8 64-bit OS. 5.x.5.0.5.x. Firefox 3.x.x Firefox 3. or IE 8. 32-bit Browsers: IE 6 SP1.x. Mozilla 1. 32-bit Browsers: Firefox 2.0. 64-bit Browsers: IE 7 or IE 8 Disk Space Windows x64 64-bit mode Windows Server 2008 Windows Vista Windows XP 128 MB 98 MB Windows 2003. IE 7.0. or Firefox 3.x.5. IE 7. 5. Firefox 3.4. Firefox 3.6 Firefox 2.5 SUSE 10 SLES 11 Linux 32-bit Memory Browsers Firefox 3.3.0.x. Netscape 7. 5. Firefox 1. 64-bit Browsers: IE 8 64-bit OS.4.0. Firefox 3.x. Firefox 2. 32-bit Browsers: Chrome 4.0.x.x.7. Firefox 1.06 3.0. 32-bit Browsers: Chrome 4.0.5. Standard Edition (R2.0.5. Firefox 3.6. 5.x.4 Red Hat Enterprise Linux 5.x.5 Red Hat Enterprise Linux 5.x.8 64-bit OS.0.0.x Disk Space 58 MB 21 . 32-bit Browsers: Mozilla 1.0. 9.6 or 3.0.1.6 64-bit OS.0. 32-bit 64mb Browsers: Firefox 3. or Firefox 3. 32-bit Browsers: Firefox 3.3. 64-bit OS.5.6 64-bit OS.5.0. 5. 5. 5.x.Platform Versions Oracle Enterprise Linux 5. 32-bit Browsers: Firefox 3.0 (5. 9.x. Firefox 3. 32-bit Browsers: Firefox 3. or Firefox 3. 9.2 SLES 11 Linux x64 64-bit mode SLES 10 Linux 64-bit Memory Browsers 64-bit OS.4.x. 32-bit Browsers: Firefox 2.4 64-bit OS.1. Firefox 3.2.2) SUSE 8.5. Firefox 3.0. Access to and use of a class library greatly simplifies the job of the programmer since standard. which makes them easier to understand and use. An applet is a special kind of Java program that a browser enabled with Java technology can download from the internet and run.Role of Class Library in Java Object oriented programming languages define all of their functionality in terms of objects. The class libraries provide an abstract interface to tasks that would normally depend heavily on the hardware and operating system. and windows for applets and standalone applications. Java Applet Java applet gives the interactive web development. An applet must be a subclass of the java. ready-made software routines that act as templates for programmers to use in writing programs. scroll bars. software can be implemented faster and with fewer errors. 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.Applet class.applet. Standard. 22 . pretested code is available that the programmer doesn't have to write any code. An applet is typically embedded inside a web page and runs in the context of a browser. Why use Class Library? • • • • • By reusing functions from Java's huge class library. The greatest benefits are primarily for application extensibility code re-usability and program stability. such as buttons. pretested code is available that the programmer doesn't have to write. The abstraction provided by the Java class library is cleaner. 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. okButton.applet. TextField nameField. radioGroup.*. radio2 = new Checkbox("Radio2". Checkbox radio1.100.20. radioGroup = new CheckboxGroup(). okButton = new Button("First button").setBounds(20.false). 23 .100). import java. nameField = new TextField("First TextField". option = new Checkbox("Option". radio1 = new Checkbox("Radio1". Checkbox radio2. CheckboxGroup radioGroup. Checkbox option.true).Sample Programme import java.false). public class GuiExample extends Applet { Button okButton.awt.30). public void init() { SetLayout(null).*. radioGroup. } } 24 .setBounds(20.30). add(nameField).setBounds(20. add(okButton). add(option).100. radio2.100.30).setBounds(140. add(radio2).70. radio1.170.30).40).120.100.100. add(radio1).nameField. option.120.setBounds(20. References http://wiki.com/en/download/help/sysreq.tcl.java.xml [Accessed 26 Nov 2010] 25 .tk/13398 [Accessed 15 Nov 2010] http://www.
Copyright © 2024 DOKUMEN.SITE Inc.