Hi,
im having trouble understanding how private methods are accessed, and overall how they are used.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SIT232_Ass1
{
public class Plan
{
// declares constant
private const int CHARGE_BLOCK = 30;
// declates our private variables
private decimal _MonthlyFee, _CallAllowance, _CallRate;
//creates 3 read only properties
public decimal MonthlyFee
{
get { return MonthlyFee; }
}
public decimal CallAllowance
{
get { return CallAllowance; }
}
public decimal CallRate
{
get { return CallRate; }
}
// custom or parameterised constructor - set the private with appropriate given parameter
public Plan(decimal monthlyFee, decimal callAllowance, decimal callRate)
{
_MonthlyFee = monthlyFee;
_CallAllowance = callAllowance;
_CallRate = callRate;
}
public Plan(Plan plan)
{
_MonthlyFee = Plan.MonthlyFee;
}
public decimal CalculateCallCost()
{
decimal block = (Math.Ceiling(PhoneCall._Seconds/Plan.CHARGE_BLOCK));
}
public override string ToString()
{
string.Format("{0} per month ({1} call allowance)", Plan.monthlyFee, Plan._CallAllowance);
}
}
}
This is one class in my project, for starters Im REALLY struggling to understand why I need to use so many different names for the one variable ie (MonthlyFee,_MonthlyFee and sometimes in other files there are up to 4 variations!
If one variation of the variable is changed does it change them all?
Heres the other file you will need to compile (im aware their are errors). Any help would be GREATLY appreciated
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SIT232_Ass1
{
public class PhoneCall//Complete
{
//Declares private, read only attribute Date
private string _Date;
public string Date
{
get { return _Date; }
}
//Declares private,read only attribute Minutes
private int _Minutes;
public int Minutes
{
get { return _Minutes; }
}
//Declares private, read only attribute Seconds
private int _Seconds;
public int Seconds
{
get { return _Seconds; }
}
// custom or parameterised constructor - set the private with appropriate given parameter
public PhoneCall(string date, int minutes, int seconds)
{
_Date = date;
_Minutes = minutes;
_Seconds = seconds;
}
}
}