Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
MortimerPhones3Funny.cs
Package: CSharpprogramming.rar [view]
Upload User: lxycoco
Upload Date: 2022-07-21
Package Size: 38457k
Code Size: 3k
Category:
CSharp
Development Platform:
Others
- namespace Wrox.ProCSharp.OOProg
- {
- using System;
- public enum TypeOfCall
- {
- CallToCellPhone, CallToLandline
- }
- public class Customer
- {
- private string name;
- protected decimal balance;
- public string GetFunnyString()
- {
- return "Plain ordinary customer. Kaark!";
- }
- public string Name
- {
- get
- {
- return name;
- }
- set
- {
- name = value;
- }
- }
- public decimal Balance
- {
- get
- {
- return balance;
- }
- }
- public void RecordPayment(decimal amountPaid)
- {
- balance -= amountPaid;
- }
- public virtual void RecordCall(TypeOfCall callType, uint nMinutes)
- {
- switch (callType)
- {
- case TypeOfCall.CallToLandline:
- balance += (0.02M * nMinutes);
- break;
- case TypeOfCall.CallToCellPhone:
- balance += (0.30M * nMinutes);
- break;
- default:
- break;
- }
- }
- }
- public class Nevermore60Customer : Customer
- {
- private uint highCostMinutesUsed;
- public new string GetFunnyString()
- {
- return "Nevermore60. Nevermore!";
- }
- public override void RecordCall(TypeOfCall callType, uint nMinutes)
- {
- switch (callType)
- {
- case TypeOfCall.CallToLandline:
- balance += (0.02M * nMinutes);
- break;
- case TypeOfCall.CallToCellPhone:
- uint highCostMinutes, lowCostMinutes;
- uint highCostMinutesToGo =
- (highCostMinutesUsed < 60) ? 60 - highCostMinutesUsed : 0;
- if (nMinutes > highCostMinutesToGo)
- {
- highCostMinutes = highCostMinutesToGo;
- lowCostMinutes = nMinutes - highCostMinutes;
- }
- else
- {
- highCostMinutes = nMinutes;
- lowCostMinutes = 0;
- }
- highCostMinutesUsed += highCostMinutes;
- balance += (0.50M * highCostMinutes + 0.20M *
- lowCostMinutes);
- break;
- default:
- break;
- }
- }
- }
- public class MainEntryPoint
- {
- public static void Main()
- {
- Customer cust1;
- Nevermore60Customer cust2;
- cust1 = new Customer();
- Console.WriteLine("Customer referencing Customer: "
- + cust1.GetFunnyString());
- cust1 = new Nevermore60Customer();
- Console.WriteLine("Customer referencing Nevermore60Customer: "
- + cust1.GetFunnyString());
- cust2 = new Nevermore60Customer();
- Console.WriteLine("Nevermore60Customer referencing: "
- + cust2.GetFunnyString());
- }
- }
- }