The document describes implementing a factory method design pattern to create different shape objects like circles, ellipses, rectangles and squares. It defines an interface IShape with methods to calculate area and perimeter. Classes are created for each shape inheriting the interface. A Creator class uses factory method to return the appropriate shape object based on user input character. Sample code demonstrates creating a circle object with radius 7 and computing its area and perimeter.
In today's high technology environment, organizations are becoming more and more dependent on their information systems. The public is increasingly concerned about the proper use of data and information. Most Organizations like banks, airlines, markets, manufactures and universities widely used computer systems to manage, manipulate and process their information. Many of today's most widely used computer systems are database applications, for example, Amazon, which was built on top of MySQL. Database application is involved like everywhere in our world, it touches all aspects of our lives.
A database application is a computer program whose primary purpose is entering and retrieving information from a computerized database. Early examples of database applications were accounting systems and airline reservations systems.
The aim of this course is to explore fundamentals of database application related to MySQL, phpMyAdmin, MySQL command lines, apache server and PHP Maker. It details the relational database principles. It shows how to build and develop database application with web interface.
Upon completion of this course, computer students will have gained knowledge of database application concepts and the ability to:
Must know the basic concepts related relational database application.
Must know how to manage relational database via using MySQL command line and phpMyAdmin.
Must know how to build database application with web interface by using MySQL and PHPMaker.
A combination of lectures and practical sessions will be used in this course in order to achieve the aim of the course.
By MSc. Karwan Mustafa Kareem
ZIO: Powerful and Principled Functional Programming in ScalaWiem Zine Elabidine
This is an introduction of purely functional programming type safe abstractions that provide a variety of features for building asynchronous and concurrent applications data structures built on ZIO.
You'll learn by examples about the power of functional programming to solve the hard problems of software development in a principled, without compromises.
In today's high technology environment, organizations are becoming more and more dependent on their information systems. The public is increasingly concerned about the proper use of data and information. Most Organizations like banks, airlines, markets, manufactures and universities widely used computer systems to manage, manipulate and process their information. Many of today's most widely used computer systems are database applications, for example, Amazon, which was built on top of MySQL. Database application is involved like everywhere in our world, it touches all aspects of our lives.
A database application is a computer program whose primary purpose is entering and retrieving information from a computerized database. Early examples of database applications were accounting systems and airline reservations systems.
The aim of this course is to explore fundamentals of database application related to MySQL, phpMyAdmin, MySQL command lines, apache server and PHP Maker. It details the relational database principles. It shows how to build and develop database application with web interface.
Upon completion of this course, computer students will have gained knowledge of database application concepts and the ability to:
Must know the basic concepts related relational database application.
Must know how to manage relational database via using MySQL command line and phpMyAdmin.
Must know how to build database application with web interface by using MySQL and PHPMaker.
A combination of lectures and practical sessions will be used in this course in order to achieve the aim of the course.
By MSc. Karwan Mustafa Kareem
ZIO: Powerful and Principled Functional Programming in ScalaWiem Zine Elabidine
This is an introduction of purely functional programming type safe abstractions that provide a variety of features for building asynchronous and concurrent applications data structures built on ZIO.
You'll learn by examples about the power of functional programming to solve the hard problems of software development in a principled, without compromises.
A function is a set of statements that take inputs, do some specific computation and produces output. The idea is to put some commonly or repeatedly done task together and make a function, so that instead of writing the same code again and again for different inputs, we can call the function.
Python provides built-in functions like print(), etc. but we can also create your own functions. These functions are called user-defined functions.
An Introduction to Programming in Java: ArraysMartin Chapman
An Introduction to Programming in Java: Arrays. Last delivered in 2012. All educational material listed or linked to on these pages in relation to King's College London may be provided for reference only, and therefore does not necessarily reflect the current course content.
A personal Blogging website.
Language: PHP, MySQL, HTML, CSS
Developed By: Shahid, CSE, KU
Features:
The system we have developed allows users to create their own blog, where users can publish their own opinions.
In this system, there are admins who take care of the Blog.
If anyone wants to post first they will have to create a new blog as well as a site account.
The posts may be verified by the admins.
There has category list where posts can be saved by relevant category.
People can like, comment and share the posts
Full responsive, Compatible with pc, tab, and mobile devices
Like, Comment featured
Has pagination feature
Templates may be used in many combinations with inheritance. It is possible to combine inheritance and templates because a template class is a class, albeit one with a parameter. Combining these language features allows the parameterization ability of templates to be used in conjunction with the specializing abilities of inheritance. Four combinations of templates and inheritance are presented in this section:
a template class that inherits from another template class,
a non-template class that inherits from a template class,
a template class that inherits from a non-template class, and
a template class that uses multiple inheritance.
Each of these combinations will be illustrated by an example showing how the two features are combined and what advantages are possibly gained by using them together.
In this presentation, I give an introduction to Windows PowerShell:
- What is it, and how does it work?
- How can you extend it to provide support for administering your own product or project?
NOTES:
1) Some of the text in this presentation is a little small for reading in a 400 pixel flash viewer. I'd recommend downloading the presentation instead.
2) The slides might not make sense without the notes that go with them. I've added the notes as comments to each slide. They still might not make much sense, but that's a different problem :-)
This presentation educates you about Python - Network Programming, What are Sockets?, Sockets have their own vocabulary, The socket Module, Server Socket Methods, Client Socket Methods and General Socket Methods.
For more info stay tuned with Learnbay.
A function is a set of statements that take inputs, do some specific computation and produces output. The idea is to put some commonly or repeatedly done task together and make a function, so that instead of writing the same code again and again for different inputs, we can call the function.
Python provides built-in functions like print(), etc. but we can also create your own functions. These functions are called user-defined functions.
An Introduction to Programming in Java: ArraysMartin Chapman
An Introduction to Programming in Java: Arrays. Last delivered in 2012. All educational material listed or linked to on these pages in relation to King's College London may be provided for reference only, and therefore does not necessarily reflect the current course content.
A personal Blogging website.
Language: PHP, MySQL, HTML, CSS
Developed By: Shahid, CSE, KU
Features:
The system we have developed allows users to create their own blog, where users can publish their own opinions.
In this system, there are admins who take care of the Blog.
If anyone wants to post first they will have to create a new blog as well as a site account.
The posts may be verified by the admins.
There has category list where posts can be saved by relevant category.
People can like, comment and share the posts
Full responsive, Compatible with pc, tab, and mobile devices
Like, Comment featured
Has pagination feature
Templates may be used in many combinations with inheritance. It is possible to combine inheritance and templates because a template class is a class, albeit one with a parameter. Combining these language features allows the parameterization ability of templates to be used in conjunction with the specializing abilities of inheritance. Four combinations of templates and inheritance are presented in this section:
a template class that inherits from another template class,
a non-template class that inherits from a template class,
a template class that inherits from a non-template class, and
a template class that uses multiple inheritance.
Each of these combinations will be illustrated by an example showing how the two features are combined and what advantages are possibly gained by using them together.
In this presentation, I give an introduction to Windows PowerShell:
- What is it, and how does it work?
- How can you extend it to provide support for administering your own product or project?
NOTES:
1) Some of the text in this presentation is a little small for reading in a 400 pixel flash viewer. I'd recommend downloading the presentation instead.
2) The slides might not make sense without the notes that go with them. I've added the notes as comments to each slide. They still might not make much sense, but that's a different problem :-)
This presentation educates you about Python - Network Programming, What are Sockets?, Sockets have their own vocabulary, The socket Module, Server Socket Methods, Client Socket Methods and General Socket Methods.
For more info stay tuned with Learnbay.
1- Create a class called Point that has two instance variables, defi.pdfjeeteshmalani1
1- Create a class called Point that has two instance variables, defined as private, as follows: An x
coordinate and a y coordinate of type integer.
a) Write two constructors for the Point class as follows: A default constructor that sets the class
instance variables to zero and a constructor that receives two integer values and sets the instance
variables to them.
b) Write the set and get methods for the Point class to set and return the values of its instance
variables.
c) Write a toString() method for the Point class that prints the class name (Point) and the value of
its instance variables.
2- Create three classes called Circle, Rectangle and Square with the following properties:
- The Circle class has two instance variables – a position of type Point (the class that you just
created above) and a radius of type double. The instance variables position and radius specify the
position of the center and radius of the circle, respectively.
- The Rectangle class has three instance variables – a position of type Point (the class that you
just created above), a length and a width of type double. The instance variables position, length
and width specify the position of the top left corner, length and width of the rectangle,
respectively.
- The Square class has two instance variables – a position of type Point (the class that you just
created above) and a lengthof type double. The instance variables position andlength specify the
position of the top left corner and length of the square, respectively.
For each of the Circle, Rectangle andSquare classes do the following:
a) Define the instance variables as private.
b) Write two constructors for each class as follows: A default constructor that sets the instance
variables to zero and a constructor that receives values for the instance variables and sets them.
c) Write the set and get methods for each class to set and return the values of their instance
variables. For example, one of the get methods would return a Point.
d) Write a toString() method for each class that prints the class name (Circle, Rectangle or
Square) and the value of its instance variables.
e) Write two methods called getPerimeter() and getArea() for each class, which calculate and
return the perimeter and area of the class, respectively. For example, the getArea() method of the
Square class returns the area of the Square object.
3- Test the above classes by writing a class called GeometricTest.java that does the following:
- Creates instances of the Circle, Rectangle and Square classes as follows:
- Circle: positioned at x = 7, y = 3 and the radius = 4.5.
- Rectangle: positioned at x = 3, y = -1 and the length = 4.0 and width = 6.0.
- Square: positioned at x = 5, y = 8 and the length = 2.0.
- Prints each of the above objects.
- Changes the length of the Square object to 5.0.
- Prints the perimeter and area of each of each of the above objects.
- Compares the x coordinates of the Square and Rectangle classes and prints a message
spec.
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 --.
One of the most popular programming language on the market is getting even better. With every iteration of C# we get more and more features that are meant to make our lives as developers a lot easier. Join me in this session to explore what's new in C# 8, as well as what we can expect in the near (and far) future of C#!
We'll talk about:
- News in C# 8
- Pattern Matching (incl. Record Types)
- Nullable Reference Types and How to Avoid Null Reference Exceptions
- How Async & Await is Improving
Unix and Shell Programming,
Q P Code: 60305.
Additional Mathematics I
Q P Code: 60306
Computer Organization and Architecture
Q P Code: 62303
Data Structures Using C
Q P Code: 60303
Discrete Mathematical Structures
Q P Code: 60304
Engineering Mathematics - III
Q P Code: 60301
Soft Skill Development
Q P Code: 60307
1z0 851 exam-java standard edition 6 programmer certified professionalIsabella789
Guaranteed success with updated troytec dumps for 1Z0-851 Exam-Java Standard Edition 6 Programmer Certified Professional visit@ https://www.troytec.com/1Z0-851-exams.html
Similar to Assignment for Factory Method Design Pattern in C# [ANSWERS] (20)
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Hivelance Technology
Cryptocurrency trading bots are computer programs designed to automate buying, selling, and managing cryptocurrency transactions. These bots utilize advanced algorithms and machine learning techniques to analyze market data, identify trading opportunities, and execute trades on behalf of their users. By automating the decision-making process, crypto trading bots can react to market changes faster than human traders
Hivelance, a leading provider of cryptocurrency trading bot development services, stands out as the premier choice for crypto traders and developers. Hivelance boasts a team of seasoned cryptocurrency experts and software engineers who deeply understand the crypto market and the latest trends in automated trading, Hivelance leverages the latest technologies and tools in the industry, including advanced AI and machine learning algorithms, to create highly efficient and adaptable crypto trading bots
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
Large Language Models and the End of ProgrammingMatt Welsh
Talk by Matt Welsh at Craft Conference 2024 on the impact that Large Language Models will have on the future of software development. In this talk, I discuss the ways in which LLMs will impact the software industry, from replacing human software developers with AI, to replacing conventional software with models that perform reasoning, computation, and problem-solving.
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
Even though at surface level ‘java.lang.OutOfMemoryError’ appears as one single error; underlyingly there are 9 types of OutOfMemoryError. Each type of OutOfMemoryError has different causes, diagnosis approaches and solutions. This session equips you with the knowledge, tools, and techniques needed to troubleshoot and conquer OutOfMemoryError in all its forms, ensuring smoother, more efficient Java applications.
Strategies for Successful Data Migration Tools.pptxvarshanayak241
Data migration is a complex but essential task for organizations aiming to modernize their IT infrastructure and leverage new technologies. By understanding common challenges and implementing these strategies, businesses can achieve a successful migration with minimal disruption. Data Migration Tool like Ask On Data play a pivotal role in this journey, offering features that streamline the process, ensure data integrity, and maintain security. With the right approach and tools, organizations can turn the challenge of data migration into an opportunity for growth and innovation.
Designing for Privacy in Amazon Web ServicesKrzysztofKkol1
Data privacy is one of the most critical issues that businesses face. This presentation shares insights on the principles and best practices for ensuring the resilience and security of your workload.
Drawing on a real-life project from the HR industry, the various challenges will be demonstrated: data protection, self-healing, business continuity, security, and transparency of data processing. This systematized approach allowed to create a secure AWS cloud infrastructure that not only met strict compliance rules but also exceeded the client's expectations.
Advanced Flow Concepts Every Developer Should KnowPeter Caitens
Tim Combridge from Sensible Giraffe and Salesforce Ben presents some important tips that all developers should know when dealing with Flows in Salesforce.
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
Experience our free, in-depth three-part Tendenci Platform Corporate Membership Management workshop series! In Session 1 on May 14th, 2024, we began with an Introduction and Setup, mastering the configuration of your Corporate Membership Module settings to establish membership types, applications, and more. Then, on May 16th, 2024, in Session 2, we focused on binding individual members to a Corporate Membership and Corporate Reps, teaching you how to add individual members and assign Corporate Representatives to manage dues, renewals, and associated members. Finally, on May 28th, 2024, in Session 3, we covered questions and concerns, addressing any queries or issues you may have.
For more Tendenci AMS events, check out www.tendenci.com/events
Modern design is crucial in today's digital environment, and this is especially true for SharePoint intranets. The design of these digital hubs is critical to user engagement and productivity enhancement. They are the cornerstone of internal collaboration and interaction within enterprises.
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
The European Union Agency for Law Enforcement Cooperation (Europol) has suffered an alleged data breach after a notorious threat actor claimed to have exfiltrated data from its systems. Infamous data leaker IntelBroker posted on the even more infamous BreachForums hacking forum, saying that Europol suffered a data breach this month.
The alleged breach affected Europol agencies CCSE, EC3, Europol Platform for Experts, Law Enforcement Forum, and SIRIUS. Infiltration of these entities can disrupt ongoing investigations and compromise sensitive intelligence shared among international law enforcement agencies.
However, this is neither the first nor the last activity of IntekBroker. We have compiled for you what happened in the last few days. To track such hacker activities on dark web sources like hacker forums, private Telegram channels, and other hidden platforms where cyber threats often originate, you can check SOCRadar’s Dark Web News.
Stay Informed on Threat Actors’ Activity on the Dark Web with SOCRadar!
Cyaniclab : Software Development Agency Portfolio.pdfCyanic lab
CyanicLab, an offshore custom software development company based in Sweden,India, Finland, is your go-to partner for startup development and innovative web design solutions. Our expert team specializes in crafting cutting-edge software tailored to meet the unique needs of startups and established enterprises alike. From conceptualization to execution, we offer comprehensive services including web and mobile app development, UI/UX design, and ongoing software maintenance. Ready to elevate your business? Contact CyanicLab today and let us propel your vision to success with our top-notch IT solutions.
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
How Recreation Management Software Can Streamline Your Operations.pptx
Assignment for Factory Method Design Pattern in C# [ANSWERS]
1. 1 of 4
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Author: Kasun Ranga Wijeweera
Email: krw19870829@gmail.com
Date: 2020 April 11
1) Design a system to handle the shapes: circles, ellipses, rectangles and squares. Use the
Factory Method design pattern according to the instructions given below. Read all the steps
carefully before you begin answering the questions.
a) The interface should have two method prototypes for computing the area and
perimeter of the shapes.
interface IShape
{
double GetArea ();
double GetPerimeter ();
}
b) Create classes for each of the shapes. You should use inheritance appropriately.
class Circle : IShape
{
protected double a;
public Circle (double a)
{
this.a = a;
}
public virtual double GetArea ()
{
return Math.PI * Math.Pow(a, 2);
}
public virtual double GetPerimeter ()
{
return 2 * Math.PI * a;
}
}
2. 2 of 4
class Ellipse : Circle
{
double b;
public Ellipse (double a, double b) : base(a)
{
this.b = b;
}
public override double GetArea ()
{
return Math.PI * a * b;
}
public override double GetPerimeter ()
{
return 2 * Math.PI * Math.Sqrt ((Math.Pow (a, 2) + Math.Pow (b, 2)) / 2);
}
}
class Square : IShape
{
protected double a;
public Square (double a)
{
this.a = a;
}
public virtual double GetArea ()
{
return Math.Pow (a, 2);
}
public virtual double GetPerimeter ()
{
return 4 * a;
}
}
3. 3 of 4
class Rectangle : Square
{
double b;
public Rectangle(double a, double b) : base(a)
{
this.b = b;
}
public override double GetArea ()
{
return a * b;
}
public override double GetPerimeter ()
{
return 2 * a + 2 * b;
}
}
c) The object should be created based on the user inputs as shown in table below.
User input Object type
c Circle object
r Rectangle object
s Square object
e Ellipse object
class Creator
{
public IShape FactoryMethod (char ch, double a, double b)
{
if (ch == 'c')
{
return new Circle (a);
}
else if (ch == 's')
{
return new Square (a);
}
else if (ch == 'e')
{
return new Ellipse (a, b);
4. 4 of 4
}
else if (ch == 'r')
{
return new Rectangle (a, b);
}
}
}
d) Create a circle object with the radius = 7.
Creator c = new Creator ();
IShape shape;
shape = c.FactoryMethod (‘c’, 7, 0);
e) Compute the area and perimeter of the circle object created in (1) (d) above.
Console.WriteLine ("Circle area: {0}", shape.GetArea ());
Console.WriteLine ("Cirlce perimeter: {0}", shape.GetPerimeter ());
Note:
1. Circle of radius = r.
a. Area = πr2
b. Perimeter = 2πr
2. Ellipse of radii a and b.
a. Area = πab
b. Perimeter = 2π√{(a2
+b2
)/2}