-
private public
hello.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Uppgift_1
{
class Product
{
private string Produuct;
private decimal Price;
private decimal Vat;
private bool Food;
private int Count;
private const decimal foodVATRate = 0.12m, otherVATRate = 0.25m;
private decimal Finalprice;
private decimal Rate;
public void Readinput()
{
Console.Write("Made by ");
Console.Write("\n+++++++++++++++++++++++++++++++++++");
}
public void Readname()
{
Console.Write("\n\nWhat is the product you want: ");
Produuct = Console.ReadLine();
}
public void Readprice ()
{
Console.Write("Unit price: ");
decimal.TryParse(Console.ReadLine(), out Price);
}
public void readFooditem()
{
Console.Write("Food item y/n: ");
char answer = char.Parse(Console.ReadLine());
if ((answer == 'y') || (answer == 'Y'))
{
Food = true;
Vat = foodVATRate;
}
else
{
Food = false;
Vat = otherVATRate;
}
}
public void readcount()
{
Console.Write("Count: ");
int.TryParse(Console.ReadLine(), out Count);
}
public void readcalculate()
{
Finalprice =Price * Count;
Rate = Finalprice * Vat;
}
public void PrintRecept()
{
Console.Write("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++");
Console.Write("\n\nThe product you want is: " + Produuct);
Console.Write("\nThe price: "+ Price);
Console.Write("\nFood item: "+Food);
Console.Write("\nCount: "+Count);
Console.Write("\n\nTotal price: "+Finalprice);
Console.Write("\nVAT at "+ Rate);
Console.Write("\n\n++++++++++++++++++++++++++++++++++++++++++++++++++++++");
}
}
}
i need to change it so it looks like samthing like this.
public void start
{
readinput()
calculate()
printrecept()
}
private void readinput()
private void calculate()
private void printrecept()
But if i do this nothing will come up on the screen becous it is private
-
Re: private public
You're function is called ReadInput, but it doesn't really take any input. Your ReadInput function basically just displays
Made by
+++++++++++++++++++++++++++++++++++
You must first call all those functions that take in input. After that call the calculate function. And then finally call the printreciept function.
Btw, I could be wrong but I don't think 'start' is the right word to be used there. It's usually 'Main'.
So it goes like 'Public static void Main()'.
-
Re: private public
In your example at the bottom your start routine is public and calls the others, This would work provided you call the start routine from elsewhere.
Your readinput call is bogus as pointed out above. You would need to call the actual input routines.