You are on page 1of 5

Official (Closed) - Non Sensitive

PS11-12 Hoh Jungi

Lesson08Ex1

Filename: Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;

namespace Lesson08Ex1
{
class ElectronicsShop
{
private string strShopName;

public ElectronicsShop(string s)
{
strShopName = s;
}

public virtual string GetDiscount()


{
return "0%";
}
}
class Computer : ElectronicsShop
{
private string strBrand;

public Computer(string Brand, string ShopName) : base(ShopName)


{

LastSaved 20230505T2011 page 1 of 5


Official (Closed) - Non Sensitive
PS11-12 Hoh Jungi

strBrand = Brand;
}

public override string GetDiscount()


{
return "10%";
}
}

class Phone : ElectronicsShop


{
string strModel;

public Phone(string Model, string ShopName) : base(ShopName)


{
strModel = Model;
}
}

internal class Program


{
static void Main(string[] args)
{
Computer objCom;

Console.WriteLine("Enter the brand of the computer:");


string brand = Console.ReadLine();
Console.WriteLine("Enter the name of the electronics shop:");
string shopname = Console.ReadLine();

objCom = new Computer(shopname, brand);

Console.WriteLine("Discount: " + objCom.GetDiscount());

Phone objPhone;

Console.WriteLine("Enter the model of the phone:");


string model = Console.ReadLine();
Console.WriteLine("Enter the name of the electronics shop:");
shopname = Console.ReadLine();

objPhone = new Phone(shopname, model);

Console.WriteLine("Discount: " + objPhone.GetDiscount());

Console.ReadKey();
}
}
}

LastSaved 20230505T2011 page 2 of 5


Official (Closed) - Non Sensitive
PS11-12 Hoh Jungi

Lesson08Ex2

Filename: Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;

namespace Lesson08Ex2
{
class Picture
{
private string strTitle;
private float fltPrice;

public Picture(string t, float p)


{
strTitle = t;
fltPrice = p;
}

public virtual float GetPrice()


{
return fltPrice;
}
}
class Photograph : Picture
{
private string strPhotographer;
private string strCamera;

public Photograph(string Photographer, string Camera, string Title, float Price) : base(Title, Price)

LastSaved 20230505T2011 page 3 of 5


Official (Closed) - Non Sensitive
PS11-12 Hoh Jungi

{
strPhotographer = Photographer;
strCamera = Camera;
}

public override float GetPrice()


{
return base.GetPrice() + 30f;
}
}

class Painting : Picture


{
private string strArtist;
private string strType;

public Painting(string Artist, string Type, string Title, float Price) : base(Title, Price)
{
strArtist = Artist;
strType = Type;
}

public override float GetPrice()


{
return base.GetPrice() + 50f;
}
}

internal class Program


{
static void Main(string[] args)
{
Photograph objPhoto;

Console.Write("Enter the name of the photographer: ");


string photographer = Console.ReadLine();
Console.Write("Enter the brand of the camera: ");
string camera = Console.ReadLine();
Console.Write("Enter the title of the photograph: ");
string title = Console.ReadLine();
Console.Write("Enter the price of the photograph: ");
float price = float.Parse(Console.ReadLine());

objPhoto = new Photograph(photographer, camera, title, price);

Console.WriteLine("Price: $" + objPhoto.GetPrice());

Painting objPainting;

Console.Write("\nEnter the name of the artist: ");


string artist = Console.ReadLine();
Console.Write("Enter the type of the painting: ");
string type = Console.ReadLine();
Console.Write("Enter the title of the painting: ");
title = Console.ReadLine();
Console.Write("Enter the price of the painting: ");
price = float.Parse(Console.ReadLine());

objPainting = new Painting(artist, type, title, price);

Console.WriteLine("Price: $" + objPainting.GetPrice());

LastSaved 20230505T2011 page 4 of 5


Official (Closed) - Non Sensitive
PS11-12 Hoh Jungi

Console.ReadKey();
}
}
}

LastSaved 20230505T2011 page 5 of 5

You might also like