You are on page 1of 7

Mobile Computing

(Assignment 1)
__________________________________________________________________

Submitted to:

Prof Mubbasher Mustaq

Submitted by:

Khawar Zaman Abbasi

Roll no: BITF18A029

Punjab University College of Information Technology,

PUCIT (Old Campus),

LAHORE
OOP CONCEPTS
Class:

class Student {

var stdName;

var stdAge;

var stdRoll_nu;

showStdInfo() {

print("Student Name is : ${stdName}");

print("Student Age is : ${stdAge}");

print("Student Roll Number is : ${stdRoll_nu}")

Object:

void main () {

var std = new Student();

std.stdName="Khawar";

std.showStdInfo();

Inheritance:
class Bird{

void fly()

print("The bird can fly");

class Parrot extends Bird{

void speak(){

print("The parrot can speak");

void main() {

Parrot p=new Parrot();

p.speak();

p.fly();

Interfaces:

class Printer {

void print_data() {

print("Print Value");

class ConsolePrinter implements Printer {

void print_data() {

print("Printing to Console");

}
void main() {

ConsolePrinter cp= new ConsolePrinter();

cp.print_data();

Abstraction:
abstract class Person {

void displayInfo();

class Boy extends Person

void displayInfo() {

print("My name is Khawar");

class Man extends Person

void displayInfo() {

print("My name is Abbasi");

void main() {
Boy b = new Boy();

Man g = new Man();

b.displayInfo();

g.displayInfo();

Polymorphism:
class Human{

void run()

print("Human is running");

class Man extends Human{

void run(){

print("Boy is running");

void main(){

Man m = new Man();

m.run();

Encapsulation:
library cake;

class MainCake{
//non-private property

//list of strings

List<String> randomPieceOfCakes = ['cake3', 'cake4', 'cake5', 'cake6'];

//private properties

String _pieceOfCake1 = "cake1";

String pieceOfCake2 = "cake2";

import 'cake.dart';

void main(){

MainCake newCake = new MainCake();

//non-private property - randomPieceOfCakes

print(newCake.randomPieceOfCakes);

//private property - piece of cake

print(newCake._pieceOfCake1); // private property error

// non-private private - piece of cake

print(newCake.pieceOfCake2);

You might also like