Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Declare and initialize the class
Reassign at least two class variables using class properties
Make two class method calls

What I have tried:

public class Dice
{
private int topFace = 1;
private Random myRand = new Random();

public void Roll()
{
// ......
}
}
Posted
Comments
Kevin Marois 5-Feb-16 13:49pm    
Since you're new here... no one here is going to do your homework for you. What have you tried? Is there a particular problem you're having?
Sergey Alexandrovich Kryukov 5-Feb-16 14:05pm    
I don't think the formulation of the assignment is literal. "Reassign at least two class variables using class properties..."
—SA

1 solution

There are no properties in your Dice class - and your homework specifically wants you to use two. Similarly, you need to declare two public methods in your class so they can be called - you don't have any.

OK, we can't see your actual homework - and we wouldn't do it for you if we could, you will learn a lot more by doing it yourself.
But the syntax for a property is
C#
private TypeOfProperty _PropertyName; // Backing store
public TypeOfProperty PropertyName    // Property
   {
   get { return _PropertyName; }
   set { _PropertyName = value; }
   }
Methods you already know how to declare and implement.
So all you need to do is create two methods, and two properties.
Then in your Main method, create an instance of the class, use the setters, and call the methods.
It shouldn't take you very long - this isn't complicated!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900