Assignment 5

Similar to last assignment, in this assignment, you will create two classes: A MainClass and a second class which is used in the main class.

1- Choose any entity/concept that can be modeled as class and object (except “course” and “car” which we have already modeled), and define a class for it (hereafter referred to as YourClass).

YouClass should have:

1. One meaningful integer attribute and one meaningful string attribute that can be read and written. (e.g. attributes “year” and “color” for class/object “car”)

Hint1: The attributes should be private

Hint2: use get and set for each attribute (in a public property)

2. A method SetAttributes() that takes two parameters for and initializes the two attributes to those parameters (do not use constructors)

Hint: use the convention for naming the parameters as “inAttribute”

3. A method PrintInfo () which will print out the two attributes of any object of your class

Hint: use Console.WriteLine(….) syntax inside your method

Once you have designed YourClass, write a MainClass with a main method. Your main method should:

1. Instantiate 2 objects of YourClass (hereafter referred to as obj1 and obj2) and initialize them with inputs from the user.

Hint1: user Console.Readline() for input from user

Hint2: use your SetAttributes to initialize your attributes

Hint: Do not forget to compile and debug your code at this point. Your code should compile and run without any error so far.

2. Compare the integer attributes of the two objects and identify the object (objX, where X is 1 or 2) with the larger integer attribute.

3. Print this object’s attributes using the PrintInfo() method you created

Hint: Use objX.PrintInfo() syntax in your main class
Powered by