Friday, September 13, 2013

Why am I getting a "the name does not exist in the current context" error on this C# program?

Why am I getting a "the name does not exist in the current context" error
on this C# program?

//Author:
//Date Created: Monday, September 9, 2013
//This is the tester class for the project for Exercise 8 in Chapter 4.
//Statement of Authenticity:
//I certify that all work in this assignment has been completed by me...
//Signed by:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Exercise8
{
class Park
{
Park aPark = new Park();
private string name;
public string Name
{
get
{
name = Console.ReadLine();
return name;
}
set
{
}
}
private string location;
public string Location
{
get
{
location = Console.ReadLine();
return location;
}
set
{
}
}
private string facilityType;
public string FacilityType
{
get
{
facilityType = Console.ReadLine();
return facilityType;
}
set
{
}
}
private string facilitiesAvailable;
public string FacilitiesAvailable
{
get
{
facilitiesAvailable = Console.ReadLine();
return facilitiesAvailable;
}
set
{
}
}
private double fee;
public string sFee;
public double Fee
{
get
{
fee = double.Parse(sFee);
sFee = Console.ReadLine();
return fee;
}
set
{
}
}
private int noOfEmployees;
public string sNoOfEmployees;
public int NoOfEmployees
{
get
{
noOfEmployees = int.Parse(sNoOfEmployees);
sNoOfEmployees = Console.ReadLine();
return noOfEmployees;
}
set
{
}
}
//variables for Cost Per Visitor.
//noVisitors will be used in Calculate Revenue
public double costPerVisitor;
public double annualBudget = 200000;
public double noVisitors = 10000;
public double CalculateCostPerVisitor(double annualBudget, double
noOfVisitors)
{
//divide annual budget by number of visitors
return costPerVisitor = annualBudget / noVisitors;
}
//Calculate Revenue
public double revenue;
public double CalculateRevenue(double noOfVisitors,double fee)
{
//No of Visitors times Fee
revenue = noVisitors * fee;
return revenue;
}
public override string ToString()
{
return "Name of park: " + this.Name + "\nLocation: " +
this.Location + "\nFacility Type: " + this.FacilityType +
"\nFacility Fee: " + this.Fee + "\nNumber of employees: " +
this.NoOfEmployees +
"\nNumber of visitors recorded in the past 12 months: " +
this.noVisitors + "Annual Budget: " + this.annualBudget;
}
}
}
Error 1 The name 'CalculateCostPerVisitor' does not exist in the current
context line 36 column 61 Exercise8
Error 2 The name 'CalculateRevenue' does not exist in the current context
line 38 column 45 Exercise8
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Exercise8
{
class Program
{
public static void main (String [] args)
{
//Instantiate Objects
Park aPark = new Park();
//Call Methods
Console.WriteLine("Name of park: " + aPark.Name + "; Location
of park: " + aPark.Location + "; Type of park: " +
aPark.FacilityType);
Console.WriteLine("Name of park: " + aPark.Name + "; Location
of park: " + aPark.Location + "; Facilities available: " +
aPark.FacilitiesAvailable);
Console.WriteLine("Annual cost per visitor: " +
CalculateCostPerVisitor());
Console.WriteLine("Revenue: " + CalculateRevenue());
//Below should hopefully return To String
Console.WriteLine(aPark.ToString());
}
}
}

No comments:

Post a Comment