Scenario:
You have been tasked by a telecommunication company to develop a payment
system. This system is part of a bigger one. Although the company has many
payment models, for the purposes of this project, we shall be limited to only the
following entities:-
(i) Fixed Line Services
(ii) Mobile Services
The company has subscribers which it keeps track of, so that it knows what bills to generate at the end of a billing cycle. Fixed Line Services form part of the subscribers. This service consists of a fixed line rental and a call chargedepending on how much the service is used. Mobile service consists of a callcharge and optional SMS and 3G charges.Your system shall be a console based program. It shall offer the user, the abilityto input in details of fixed and mobile services. Lastly, it shall have to ability tocalculate the total bill payment of the fixed and mobile services in the system.
It is expected that you will be using object oriented features and concepts such as
Classes, Objects, Inheritance, etc.
so far i have done this: (i get the idea of how the basic structure should look like but i am lost on how to implement and store data in the classes)
using
System;using
System.Collections.Generic;using
System.Text;public
abstract class telephonysystem{
class Telephony
{
string subscribername;
string ServiceType;
decimal CallCharges;
public string getName()
{
return subscribername;
}
public void setName()
{
subscribername = sn;
}
public string getService()
{
return ServiceType;
}
public void setService()
{
ServiceType = st;
}
public decimal getCharges()
{
return CallCharges;
}
public void setCharges()
{
CallCharges = cc;
}
}
class MoblieService:Telephony
{
decimal FixedLineRental;
public decimal getLine()
{
return FixedLineRental;
}
public void setLine()
{
FixedLineRental=flr;
}
}
class FixedlineService:Telephony
{
decimal smsCharges;
decimal threeGCharges;
public decimal getSms()
{
return smsCharges;
}
public void setSms()
{
smsCharges = sc;
}
public decimal get3g()
{
return threeGCharges;
}
public void set3g()
{
threeGCharges=tgc;
}
}
}
namespace
Telephony{
class Program
{
static void Main(string[] args)
{
int line;
Console.WriteLine("1.Fixed Line accounts");
Console.WriteLine("2.Mobile Line accounts");
Console.WriteLine("3.Exit");
Console.WriteLine("Please select a line type: ");
switch (line)
{
case 1:
break;
case 2:
break;
}
}
}
}
Posted Dec 26, 2007, 6:08 PM
using System;
using System.Collections.Generic;
using System.Text;
public abstract class TelephonySystem
{
class Telephony
{
private string subscribername;
private string serviceType;
private decimal callCharges;
//Protected properties are only accessible
//by derived members. In other words
//only classes that inherit from this class
//will be able to access this properties.
protected string SubscriberName
{
get { return subscriberName; }
set { subscriberName = value; }
}
protected string ServiceType
{
get { return serviceType; }
set { serviceType = value; }
}
protected decimal CallCharges
{
get { return callCharges; }
set { callCharges = value; }
}
}
class MobileService : Telephony
{
private decimal fixedLineRental;
public decimal FixedLineRental
{
get { return fixedLineRental; }
set { fixedLineRental = value; }
}
}
class FixedLineService : Telephony
{
private decimal smsCharges;
private decimal threeGCharges;
public decimal SmsCharges
{
get { return smsCharges; }
set { smsCharges = value; }
}
public decimal ThreeGCCharges
{
get { return smsCharges; }
set { smsCharges = value; }
}
}
}
namespace TelephonyProgram
{
class Program
{
static void Main(string[] args)
{
private int line;
Console.WriteLine("1.Fixed Line accounts");
Console.WriteLine("2.Mobile Line accounts");
Console.WriteLine("3.Exit");
Console.WriteLine("Please select a line type: ");
switch (line)
{
case 1:
break;
case 2:
break;
}
}
}
}
Basically, a property allows you restricted access to a normally private or protected variable in the class. This allows you finer grain and more secure control over your variables. the "get" accessor basically allows the variable to be read, while the "set" accessor allows the variable to be assigned to. Using separate methods to do that is the C++ way :P Well, thats all Im gonna give you for now. Just take a look at it and see what you can figure out.
And Ryan, shame on you for not being in the holiday spirit! lol. Even if it wasnt the holidays, I still help my fellow developers out. I never just GIVE them the answers, but I show them better ways or the right way to do something and try to explain my reasons and methodology the best that I can so they will understand what they are seeing :)
Ryan AlfordPosted Dec 26, 2007, 10:05 AM