This document provides an overview of iLab 7, which introduces students to polymorphism concepts like abstract classes, virtual functions, and late binding through creating geometric shape classes. Students will create a base Shape class and derived Circle and Rectangle classes, overriding abstract area() and perimeter() functions. Objects will be created and tested, then a pointer array will access objects to call a nonmember display function, demonstrating static and dynamic binding. The deliverables are source code and a lab report specifying the program, test plan, conclusions, UML diagram, and answers to questions.
This lab introduces students to the concepts of polymorphism, early binding, late binding, abstract classes, and virtual class functions. This will be done in the context of performing calculations on basic geometrical shapes. Polymorphism is a very powerful extension of inheritance, and by using pointers to the base class, it allows access to derived class objects and their functions based on the context that they are called in.
The lab will require the creation of a base geometric class, called Shape, and two sub classes, Circle and Rectangle, that are derived public from the class Shape. From there, objects of both the Circle and the Rectangle classes will be created, as will an array of pointers to the base class Shape. By using the instantiated objects and the object pointers, both static and dynamic binding will be demonstrated.
Deliverables
1. Submit a single NotePad file containing the source code for all the lab files to the Week 7 Dropbox. Your source code should use proper indentation and be error free. Be sure that your last name and the lab number are part of the file name: for example, YourLastName_Lab5.txt.
Each program should include a comment section that includes, at a minimum, your name, the lab and exercise number, and a description of what the program accomplishes.
This lab introduces students to the concepts of polymorphism, early binding, late binding, abstract classes, and virtual class functions. This will be done in the context of performing calculations on basic geometrical shapes. Polymorphism is a very powerful extension of inheritance, and by using pointers to the base class, it allows access to derived class objects and their functions based on the context that they are called in.
The lab will require the creation of a base geometric class, called Shape, and two sub classes, Circle and Rectangle, that are derived public from the class Shape. From there, objects of both the Circle and the Rectangle classes will be created, as will an array of pointers to the base class Shape. By using the instantiated objects and the object pointers, both static and dynamic binding will be demonstrated.
This lab introduces students to the concepts of polymorphism, early binding, late binding, abstract classes, and virtual class functions. This will be done in the context of performing calculations on basic geometrical shapes. Polymorphism is a very powerful extension of inheritance, and by using pointers to the base class, it allows access to derived class objects and their functions based on the context that they are called in.
The lab will require the creation of a base geometric class, called Shape, and two sub classes, Circle and Rectangle, that are derived public from the class Shape. From there, objects of both the Circle and the Rectangle classes will be created, as will an array of pointers to the base class Shape. By using the instantiated objects and the object pointers, both static and dynamic binding will be demonstrated.
Deliverables
1. Submit a single NotePad file containing the source code for all the lab files to the Week 7 Dropbox. Your source code should use proper indentation and be error free. Be sure that your last name and the lab number are part of the file name: for example, YourLastName_Lab5.txt.
Each program should include a comment section that includes, at a minimum, your name, the lab and exercise number, and a description of what the program accomplishes.
This lab introduces students to the concepts of polymorphism, early binding, late binding, abstract classes, and virtual class functions. This will be done in the context of performing calculations on basic geometrical shapes. Polymorphism is a very powerful extension of inheritance, and by using pointers to the base class, it allows access to derived class objects and their functions based on the context that they are called in.
The lab will require the creation of a base geometric class, called Shape, and two sub classes, Circle and Rectangle, that are derived public from the class Shape. From there, objects of both the Circle and the Rectangle classes will be created, as will an array of pointers to the base class Shape. By using the instantiated objects and the object pointers, both static and dynamic binding will be demonstrated.
Object Oriented Programming Lab Manual Abdul Hannan
Object oriented programing Lab manual for practicing and improve the coding skills of object oriented programming.
Published by Mohammad Ali Jinnah University Islamabad.
java notes, object oriented programming using java, java tutorial, lecture notes, java programming notes, java example programs, java programs with explanation, java source code with output, java programs, java coding, java codes, java slides, java notes,command line arguments in java, java command line arguments notes, java command line arguments notes,different types of command line arguments in Java,command line arguments with an example, command line arguments in Java
CIS 1403 lab 3 functions and methods in JavaHamad Odhabi
This lab discusses and provides examples of both built-in and user-defined functions. In Java function are referred to as methods. Therefore, in the rest of this lab, the term methods will be used to refer to functions. The lab will cover the type of methods, naming of functions, the scope of variables and recursion.
Object Oriented Programming Lab Manual Abdul Hannan
Object oriented programing Lab manual for practicing and improve the coding skills of object oriented programming.
Published by Mohammad Ali Jinnah University Islamabad.
java notes, object oriented programming using java, java tutorial, lecture notes, java programming notes, java example programs, java programs with explanation, java source code with output, java programs, java coding, java codes, java slides, java notes,command line arguments in java, java command line arguments notes, java command line arguments notes,different types of command line arguments in Java,command line arguments with an example, command line arguments in Java
CIS 1403 lab 3 functions and methods in JavaHamad Odhabi
This lab discusses and provides examples of both built-in and user-defined functions. In Java function are referred to as methods. Therefore, in the rest of this lab, the term methods will be used to refer to functions. The lab will cover the type of methods, naming of functions, the scope of variables and recursion.
CSC139 Chapter 10 Lab Assignment (2)
Polymorphism
Objectives
In this lab assignment, students will learn:
- How to design and define interface
- How to implement methods declared in interface
- How to implement polymorphism
Goals
In this lab assignment, students will demonstrate the abilities to:
- Design and define interface
- Implement methods declared in interface
- Implement polymorphism
Grading
- Define interface (30 pts)
- Define base / derived classes (40 pts)
- Define tester program to implement polymorphism (30 pts)
In this lab you will create an interface inheritance hierarchy and perform polymorphism in a tester program. The following is the simplified UML for the hierarchy:
1. Create a Console Application Project called “InterfaceApp”.
2. Rename the “Module1.vb” as “IShapeTester.vb”
3. Add a class definition, modify it to an Interface named “IShape” which has two members:
a. Function ToString() : String
b. Function CalculateArea() :Double
4. Add a class definition named “TwoDShape”, which is an abstract base class, the following members should be included:
a. xValue: Integer ---- instance variable
b. yValue: Integer ---- instance variable
c. Sub New(Integer, Integer) ---- constructor
d. Property X():Integer ---- get and set xValue
e. Property Y():Integer ---- get and set yValue
f. Function CalculateArea():Double ---- “MustOverride” function and implements IShape’s CalculateArea() function
g. Function ToString() ---- Overrides ToString() function in Object and implements IShape’s method, display x and y coordinate on the console window (use the following definition)
Public Overrides Function ToString() As String Implements IShape.ToString
Return ("X-coordinate: " & vbTab & xValue & vbCrLf & "Y-coordinate: " & vbTab & yValue)
End Function
5. Add a class definition named “Circle”, which inherits from “TwoDShape” class and includes the following members:
a. radiusValue: Double --- instance variable, radius of a circle
b. Sub New(Integer, Integer, Double) --- constructor
c. Property Radius():Double --- get and set radiusValue
d. Function CalculateArea():Double ---- override and implement the abstract method in base class Shape, calculate area of a circle using:
radiusValue * radiusValue * 3.14
e. Function ToString() ----- use Convert.ToString(Me.GetType()) to display the type of shape, then display X and Y coordinates by calling base class’s ToString() function, finally, display radius value on console window (use the following definition)
Public Overrides Function ToString() As String
Return (Convert.ToString(Me.GetType()) & vbCrLf & MyBase.ToString() & vbCrLf & "Radius: " & vbTab & String.Format("{0:N2}", radiusValue))
End Function
6. Add a class definition named “Square”, which inherit from “TwoDShape” class and include the following members:
a. sideValue: Double --- instance variable, side of a square
b. Sub New(Integer, Integer, Double) --- constructor
c. Property Side():Double --.
1 Project 2 Introduction - the SeaPort Project seri.docxhoney725342
1
Project 2
Introduction - the SeaPort Project series
For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports.
Here are the classes and their instance variables we wish to define:
SeaPortProgram extends JFrame
o variables used by the GUI interface
o world: World
Thing implement Comparable <Thing>
o index: int
o name: String
o parent: int
World extends Thing
o ports: ArrayList <SeaPort>
o time: PortTime
SeaPort extends Thing
o docks: ArrayList <Dock>
o que: ArrayList <Ship> // the list of ships waiting to dock
o ships: ArrayList <Ship> // a list of all the ships at this port
o persons: ArrayList <Person> // people with skills at this port
Dock extends Thing
o ship: Ship
Ship extends Thing
o arrivalTime, dockTime: PortTime
o draft, length, weight, width: double
o jobs: ArrayList <Job>
PassengerShip extends Ship
o numberOfOccupiedRooms: int
o numberOfPassengers: int
o numberOfRooms: int
CargoShip extends Ship
o cargoValue: double
o cargoVolume: double
o cargoWeight: double
Person extends Thing
o skill: String
Job extends Thing - optional till Projects 3 and 4
o duration: double
o requirements: ArrayList <String>
// should be some of the skills of the persons
PortTime
o time: int
Eventually, in Projects 3 and 4, you will be asked to show the progress of the jobs using JProgressBar's.
2
Here's a very quick overview of all projects:
1. Read a data file, create the internal data structure, create a GUI to display the structure, and let
the user search the structure.
2. Sort the structure, use hash maps to create the structure more efficiently.
3. Create a thread for each job, cannot run until a ship has a dock, create a GUI to show the
progress of each job.
4. Simulate competing for resources (persons with particular skills) for each job.
Project 2 General Objectives
Project 2 - Map class, Comparator, sorting
Use the JDK Map class to write more efficient code when constructing the internal data
structures from the data file.
Implement SORTING using the Comparator interface together with the JDK support for sorting
data structures, thus sorting on different fields of the classes from Project 1.
Extend the GUI from Project 1 to let the user sort the data at run-time.
Documentation Requirements:
You should start working on a documentation file before you do anything else with these projects, and
fill in items as you go along. Leaving the documentation until the project is finished is not a good idea for
any number of reasons.
The documentation should include the following (graded) elements:
Cover page (including name, date, project, your class information)
Design
o including a UML class diagram
o classes, variables and methods: what they mean and why they are there
o tied to the requirements of the project
User's Guide
o how would a user start and run your pro ...
EN3085 Assessed Coursework 1 1. Create a class Complex .docxgidmanmary
EN3085 Assessed Coursework 1
1. Create a class Complex to allow programmers the easy use of complex numbers in their programs. An
object of that class should: [5]
a. Be able to store a complex number in the most efficient way.
b. Make use of constructor and destructor functions if needed. The
constructor should take three arguments: a character indicating if the last
two arguments should be interpreted as real and imaginary parts or
magnitude and angle, and two real numbers defining the value of the
complex number. The constructor should also initialise the members of
the object appropriately, including for cases when it receives only some
or no arguments.
c. Be able to return individual element of the complex number in both
rectangular (real and imaginary) and polar form (magnitude and angle).
d. Allow modification of the stored complex number by enabling the
modification of individual elements of the complex number (both in rectangular and polar form).
e. Include a function to print on the screen the complex number, either in rectangular or polar form.
2. Create a function GetComplexListFromFile, that: [2]
a. Reads all complex numbers recorded in a text file. Each data line in the text file always consist of one of
the following, to define a complex number:
• a letter ‘p’ followed by a magnitude and an angle (in radians), all separated by a space.
• a letter ‘r’ followed by the real and imaginary parts, all separated by a space.
b. Creates for each of them an object of type Complex.
c. Stores each created Complex object in a vector to obtain a list of all complex number defined in the file.
d. Returns the resulting vector to the function call location.
3. Create a function SaveComplexListToFile that saves a provided list of Complex objects into a text file, using
the same text file format mentioned in question 2.a. [2]
4. Using the Complex class and the functions developed previously, write a main function which will in the
order provided below: [2]
a. Stores in a vector ComplexList all complex number stored in the provided file "ComplexList.txt".
b. Prints on the screen, in both rectangular and polar forms, all complex numbers stored in ComplexList.
c. Keeps asking on the screen if the user wants to add a complex number to the list and if so asks for the
relevant information and stores the provided new complex number in the vector ComplexList.
d. Saves all the object stored in ComplexList in the file "ComplexList.txt".
5. Expand the class Complex with the following overloaded member operators: binary operators "+", "-", "*",
and "/" and a unary operator "-". [4]
The operators should return complex numbers only in rectangular form and provide the standard
functionality for arithmetic operations on complex numbers. Using these operators, in the main function:
a. Calculate the sum of all complex number stored in the vector ComplexList, after the reading of the
file "ComplexList.t ...
Dear students get fully solved assignments
Send your semester & Specialization name to our mail id :
help.mbaassignments@gmail.com
or
call us at : 08263069601
1. COMP/220 iLab 7 of 7 - C++ Course
iLab 7 of 7: Polymorphism
iLAB OVERVIEW
Scenario and Summary
This lab introduces students to the concepts of polymorphism, early binding, late binding, abstract
classes, and virtual class functions. This will be done in the context of performing calculations on
basic geometrical shapes. Polymorphism is a very powerful extension of inheritance, and by using
pointers to the base class, it allows access to derived class objects and their functions based on the
context that they are called in.
The lab will require the creation of a base geometric class, called Shape, and two sub classes, Circle
and Rectangle, that are derived public from the class Shape. From there, objects of both the Circle
and the Rectangle classes will be created, as will an array of pointers to the base class Shape. By
using the instantiated objects and the object pointers, both static and dynamic binding will be
demonstrated.
Deliverables
1. Submit a single NotePad file containing the source code for all the lab files to the Week 7
Dropbox. Your source code should use proper indentation and be error free. Be sure that your last
name and the lab number are part of the file name: for example, YourLastName_Lab5.txt.
Each program should include a comment section that includes, at a minimum, your name, the lab
and exercise number, and a description of what the program accomplishes.
2. Submit a lab report (a Word document) containing the following information to the Week 7
Dropbox.
o Include your name and the lab or lab exercise number.
o Specification: Include a brief description of what the program accomplishes, including its
input, key processes, and output.
o Test Plan: Include a brief description of the method you used to confirm that your program
worked properly. If necessary, include a clearly labeled table with test cases, predicted results, and
actual results.
o Summary and Conclusions: Write a statement summarizing your predicted and actual output,
and identify and explain any differences. For conclusions, write at least one nontrivial paragraph that
explains, in detail, either a significant problem you had and how you solved it or, if you had no
significant problems, something you learned by doing the exercise.
2. o A UML Diagram: This should show all the classes, class members, access specifiers, data
types, and function arguments, along with all of the class-to-class relationships.
o Answers to Lab Questions: Include the answers to all the lab questions that are asked in the
lab steps.
Each lab exercise should have a separate section in the lab-report document.
Your lab grade is based upon
1. the formatting of your source code;
2. the use of meaningful identifiers;
3. the extent of the internal documentation;
4. the degree to which an exercises' specifications are met; and
5. the completeness of your lab report.
iLAB STEPS
STEP 1: Create a New Multifile Project
Create a new multifile project with three classes: the base class Shape, the class Circle (derived
public from Shape), and the class Rectangle (derived public from Shape). The classes will have the
following requirements.
1. The class Shape should be an abstract class with the following pure virtual functions.
a. area()
b. perimeter()
2. The class Circle should be derived public from the class Shape and override both the area()
and the perimeter() functions.
a. The perimeter() function should correctly calculate the circumference of a circle, given a
radius.
b. The area() function should correctly calculate the area of a circle, given a radius
c. Include all the necessary accessor and mutator functions to accomplish the requirements of
the class.
3. The class Rectangle should be derived public from the class Shape and override both the
area() and the perimeter() functions.
a. The perimeter() function should correctly calculate the circumference of a rectangle, given its
dimensions.
b. The area() function should correctly calculate the area of a rectangle, given its dimensions.
c. Include all the necessary accessor and mutator functions to accomplish the requirements of
the class.
3. STEP 2: Create the Test Function
Instantiate at least one object of each of the Circle and the Rectangle classes. Provide appropriate
constructors for both that will accept the necessary initialization arguments to provide the
information required for all the class member functions. Exercise and test each member function of
both classes for correct calculations and output.
STEP 3: Add a Base Class Pointer Array and an Additional Function
Add to the test function a base class array of pointers of the same dimension as the total number of
Circle and Rectangle objects that were created in the previous step. Use this pointer array to access
the Circle and the Rectangle objects to call a new, nonclass member function that will display all the
information about each object.
1. Circle objects should display radius, circumference, and area.
2. Rectangle objects should display dimensions, perimeter. and area.
The information-display function should accept as its calling parameter a pointer of the class Shape.
Run the test function to demonstrate static (early) binding using the derived class objects calling
their member functions, and run the test function to demonstrate dynamic (late) binding using the
assigned Shape class pointers to call the nonclass, member-display-information function.
CLICK HERE TO GET THE SOLUTION !!!!!!!!