TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Shashini Nagasingha
NA
26
3.6k
I'm getting errors
Aug 9 2019 8:16 PM
using System;
using SplashKitSDK;
public enum MenuOption
{
BuyStock,
SellStock,
QueryStock,
Quit
}
public class Program
{
private static void PerformStock(Stock stock)
{
int buy;
do
{
Console.WriteLine("Enter your items need to buy");
buy = Convert.ToInt32(Console.ReadLine());
stock.BuyStock(buy);
} while (false);
Console.WriteLine("Please enter a valid amount");
}
private static MenuOption ReadUserOption()
{
int option;
Console.WriteLine("********************************** ");
Console.WriteLine("******* Choose an option between [1-4]: ****** ");
Console.WriteLine("******** 1. Buy Stock ******* ");
Console.WriteLine("******** 2. Sell Stock ******* ");
Console.WriteLine("******** 3. Query Stock ******* ");
Console.WriteLine("*********4. Quit ******* ");
do
{
Console.Write("Choose an option:{1-4} : ");
try
{
option = Convert.ToInt32(Console.ReadLine());
}
catch
{
Console.WriteLine("Please enter a valid number:");
option = -1;
}
}
while (option < 1 || option > 4);
return(MenuOption)(option - 1);
}
public static void Main()
{
Stock stock = new Stock("Test Stock Item", 100);
/* test1.PrintSummary();
test1.AddStock(10);
test1.PrintSummary();
test1.PrintSummary();
Stock test2 = new Stock("New Stock", 200);
test2.PrintSummary();
test2.AddStock(10);
test2.PrintSummary();
test2.PrintSummary();*/
MenuOption userSelection;
do
{
userSelection = ReadUserOption();
switch (userSelection)
{
case MenuOption.BuyStock:
PerformStock(stock);
break;
case MenuOption.SellStock:
Console.WriteLine("Query Stock");
break;
case MenuOption.QueryStock:
Console.WriteLine("Query Stock");
break;
case MenuOption.Quit:
Console.WriteLine("Quit ......");
break;
}
} while (userSelection != MenuOption.Quit);
}
}
Program.cs(23,19): error CS1061: 'Stock' does not contain a definition for 'BuyStock' and no accessible extension method 'BuyStock' accepting a first argument of type 'Stock' could be found (are you missing a using directive or an assembly reference?) [C:\Users\User\Documents\Codes\StockManagement\StockManagement.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:02.14
I'm getting this error please help me to fix this error
Attachment:
StockManagement.zip
Reply
Answers (
2
)
How To send Whatsapp Message in C#
I download the data from Address table to excel file