Professional Documents
Culture Documents
Topic: Design Applications Using Inheritance and Abstract Classes
Topic: Design Applications Using Inheritance and Abstract Classes
Roll No: 24
Practical No: 3
Topic: Design Applications using Inheritance and Abstract Classes
Q1)Create a Windows forms application to book vehicles (2 wheelers/4 seaters/7
seaters/buses) using inheritance. The program should be capable of displaying
the cost of booking based on chosen vehicle and the km to travel. Design an
appropriate GUI.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Practical3A
{
public partial class Form1 : Form
{
int cost;
public Form1()
{
InitializeComponent();
}
class vehicle{
public int costcalculate(int dist, int cost) {
return (dist * cost);
}
}
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21
SIES College of Management Studies FYMCA (Revised), Sem II,
Roll No: 24
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21
SIES College of Management Studies FYMCA (Revised), Sem II,
Roll No: 24
}
}
}
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21
SIES College of Management Studies FYMCA (Revised), Sem II,
Roll No: 24
Q2)Create an abstract class shape that defines an abstract method area. Derive
classes circle, rectangle, square, triangle from it to calculate the area of the various
figures. Design an appropriate GUI.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Practical3B
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public abstract class Shape {
abstract public double area();
}
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21
SIES College of Management Studies FYMCA (Revised), Sem II,
Roll No: 24
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21
SIES College of Management Studies FYMCA (Revised), Sem II,
Roll No: 24
{
e.Handled = true;
}
}
}
if (comboBox1.SelectedIndex == 0) {
textBox1.Enabled = true;
textBox2.Enabled = textBox3.Enabled = textBox4.Enabled =
textBox5.Enabled = textBox6.Enabled = false;
textBox2.Text = textBox3.Text = textBox4.Text =
textBox5.Text = textBox6.Text = null;
}
if (comboBox1.SelectedIndex == 1)
{
textBox2.Enabled = true;
textBox1.Enabled = textBox3.Enabled = textBox4.Enabled =
textBox5.Enabled = textBox6.Enabled = false;
textBox1.Text = textBox3.Text = textBox4.Text =
textBox5.Text = textBox6.Text = null;
}
if (comboBox1.SelectedIndex == 2)
{
textBox3.Enabled = textBox4.Enabled = true;
textBox1.Enabled = textBox2.Enabled = textBox5.Enabled =
textBox6.Enabled = false;
textBox1.Text = textBox2.Text = textBox5.Text =
textBox6.Text = null;
}
if (comboBox1.SelectedIndex == 3)
{
textBox5.Enabled = textBox6.Enabled = true;
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21
SIES College of Management Studies FYMCA (Revised), Sem II,
Roll No: 24
}
if (comboBox1.SelectedIndex == 1 && textBox2.Text != null)
{
Square c = new Square();
c.side = Int32.Parse(textBox2.Text);
double a = c.area();
richTextBox1.Text = "Area of the Square With a side of:" +
textBox2.Text + "cm.\t\n is: " + a;
}
if (comboBox1.SelectedIndex == 2 && textBox3.Text != null &&
textBox4.Text != null)
{
Rectangle c = new Rectangle();
c.length = Int32.Parse(textBox3.Text);
c.width = Int32.Parse(textBox4.Text);
double a = c.area();
richTextBox1.Text = "Area of the Rectangle With a Length
of:" + textBox3.Text + "cm. \t\nand width of: " + textBox4.Text + "
\t\nis:" + a;
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21
SIES College of Management Studies FYMCA (Revised), Sem II,
Roll No: 24
}
if (comboBox1.SelectedIndex == 3 && textBox5.Text != null &&
textBox6.Text != null)
{
Triangle c = new Triangle();
c.base1 = Int32.Parse(textBox5.Text);
c.height = Int32.Parse(textBox6.Text);
double a = c.area();
richTextBox1.Text = "Area of the Triangle With a base of:"
+ textBox5.Text + "cm. \t\nand height of: " + textBox6.Text + " \t\nis:" +
a;
}
}
}
}
Output:
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21
SIES College of Management Studies FYMCA (Revised), Sem II,
Roll No: 24
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21
SIES College of Management Studies FYMCA (Revised), Sem II,
Roll No: 24
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21
SIES College of Management Studies FYMCA (Revised), Sem II,
Roll No: 24
namespace Practical3C
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
interface calculateInterest {
public double calculate();
}
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21
SIES College of Management Studies FYMCA (Revised), Sem II,
Roll No: 24
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21
SIES College of Management Studies FYMCA (Revised), Sem II,
Roll No: 24
textBox1.Enabled = textBox2.Enabled =
textBox3.Enabled = textBox4.Enabled = false;
textBox1.Text = textBox2.Text = textBox3.Text =
textBox4.Text = null;
}
if (comboBox1.SelectedIndex == 0)
{
textBox2.Enabled = textBox3.Enabled =
textBox1.Enabled = true;
textBox4.Enabled = false;
textBox4.Text = null;
}
if (comboBox1.SelectedIndex == 1)
{
textBox1.Enabled = textBox3.Enabled =
textBox4.Enabled = textBox2.Enabled = true;
}
}
}
if (comboBox1.SelectedIndex == 1 && textBox1.Text !=
null && textBox2.Text != null && textBox3.Text != null &&
textBox4.Text != null)
{
compoundInterest s = new compoundInterest();
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21
SIES College of Management Studies FYMCA (Revised), Sem II,
Roll No: 24
s.amount = Int32.Parse(textBox1.Text);
s.inRate = Int32.Parse(textBox2.Text);
s.time = Int32.Parse(textBox3.Text);
s.no = Int32.Parse(textBox4.Text);
double ans = s.calculate();
richTextBox1.Text = "Priciple: " + textBox1.Text +
"\t\nRate of interest: " + textBox2.Text + "\t\nTime: " +
textBox3.Text + "\t\nNo of time amount is compounded: " +
textBox4.Text+"\t\nCumpound Interest: " + ans;
}
}
Output:
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21
SIES College of Management Studies FYMCA (Revised), Sem II,
Roll No: 24
Subject: MCAL24 Advanced Web Technology Lab Academic Year Second Half 2020_21