❔ HI i need some help create this function

public class Game { private List<Product> _products = new List<Product>(); public List <Product> Products => _products; private Product _selectedProduct; private int i = 0; public Game() { Product product1 = new Product("IPhone 14",1400,"iphone.png"); Product product2 = new Product("Xiaomi 15",1000,"xiaomi.png"); Product product3 = new Product("FairLife Milk",6,"fairlifemilk.png"); Product product4 = new Product("Air Pods Max",500,"airpodsmax.png"); Product product5 = new Product("Tootsie Rolls",20,"tootsieroll.png"); PopulateProductList(product1); PopulateProductList(product2); PopulateProductList(product3); PopulateProductList(product4); PopulateProductList(product5); } public Product SelectedProduct { get { return _selectedProduct; } set { _selectedProduct = value; } } private void PopulateProductList(Product product) { _products.Add(product); } public Product GetNextProduct() { } //Get the price of the selected product (ReadOnly) private int GetCurrentProductPrice() { return _selectedProduct.Price; } //Using Enum public CheckStatus CheckGuesses( int guessedprice) { if (_selectedProduct.Price == guessedprice ) return CheckStatus.Correct; else if (_selectedProduct.Price > guessedprice) return CheckStatus.TooHigh; else return CheckStatus.TooLow; } } }
9 Replies
TheAjayEffect
TheAjayEffectOP2y ago
The method should select a product from the products list and return a copy of that product to the caller. i. Note that the price of the returned product should be changed to zero (otherwise the caller can check the price). ii. The method should also save the picked product in the private variable _selectedProduct so the class can check validate the user guesses in the CheckGuess method. the method name is GetNextProduct()
phaseshift
phaseshift2y ago
Ok. So what's the question?
TheAjayEffect
TheAjayEffectOP2y ago
create a method to this
phaseshift
phaseshift2y ago
No, we're not going to do your homework
TheAjayEffect
TheAjayEffectOP2y ago
well it not going for grade but its just pratice he assigned
phaseshift
phaseshift2y ago
Suggest you... practise then
TheAjayEffect
TheAjayEffectOP2y ago
that function is the only problem im having
phaseshift
phaseshift2y ago
If you can be more specific that will get better feedback
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server