CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2012
    Posts
    3

    Post 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;
    }
    }

  2. #2
    Join Date
    Apr 2012
    Posts
    29

    Re: I need help solving this C# problem

    What is wrong with using
    Code:
    public string StudentName{get;set;}
    which is a property.

  3. #3
    Join Date
    Jul 2012
    Posts
    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?

  4. #4
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: I need help solving this C# problem

    [ Moved thread ]
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured