-
July 12th, 2012, 10:16 PM
#1
I need help solving this C# problem
I have some code that I am unsure how to do the following to. If someone could help me out in showing me what I need to the code pasted below I would much appreciate it. I am new to the c# world!
In looking at this code you should notice a number of things:
• It does not conform to the UML diagram because the members (excepting GPA) are not implemented as properties. You must do this in your own version of the class.
• The GPA property just goes into the Transcript object (record) and returns the value. This is just a convenience, since we could have accessed the same data using myStudent.Record.GPA.
• We have used C#'s ability to initialize member values upon construction.
Here is the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Assignment2
{
class Student
{
public Student(string n)
{
Name = n;
Record = new Transcript();
}
// To do: Property implementation
public string Name;
public Transcript Record;
public double GPA
{
get
{
return Record.GPA;
}
}
public int WealthPoints = 10000;
public int PridePoints = 100;
}
}
-
July 12th, 2012, 10:25 PM
#2
Re: I need help solving this C# problem
What is wrong with using
Code:
public string StudentName{get;set;}
which is a property.
-
July 12th, 2012, 10:29 PM
#3
Re: I need help solving this C# problem
I knew that I would need to use a get and set property, but I am not sure how to take the code I have and apply it to it?
-
July 13th, 2012, 08:09 AM
#4
Re: I need help solving this C# problem
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|