C# class Time project

This is a discussion on C# class Time project within the C# Programming forums, part of the General Programming Boards category; im in college computer technician course and our teacher gave us an assignment in C# so we can refresh our ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    4

    Angry C# class Time project

    im in college computer technician course and our teacher gave us an assignment in C# so we can refresh our mind from highschool programming ( doesnt make anysense to me. im taking computer technician and i have to study prograaming?!). unfortunately, i didnt take any programming in highschool.

    our teacher gave the assignment handout and here it is

    Create a class Time with attributes: integers hour, min , sec(min and sec cannot have valuew bigger then 59). Write all basic methods, operator overloading function and all manipulating functions and manipulating functions.

    could someone please help me coding with these assignment and its explanation how it works

    i have a guide handout given out by my teacher but

    its all symbol logic sign that i couldnt understand. it makes my nose bleeding

  2. #2
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Maybe you are in a class too high then. It should have been listed somewhere that you would need what sounds like at least a 2nd semester understanding of programming. Anyways, do you know anything about programming or writing programs with classes? This class isn't hard to write, and in fact it is pretty standard ( you can find examples everywhere of a "time" class). I'd post what you have if you want people to help, even if its pseudo code. Of course if this class truly involves programming, you should learn all you can as it will probably be used later in the course/program.

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    4
    i only know visual basic programming from my first semester and for C# i know nothing my teacher said it would be easy for me coz i already kknow vb :I

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    2,588
    Quote Originally Posted by dropper166 View Post
    i only know visual basic programming from my first semester and for C# i know nothing my teacher said it would be easy for me coz i already kknow vb :I
    C# and VB are totally different. they use the same library (.Net runtime), but that's about where the similarities end. I'd suggest a good C# book or online tutorial to get you going. try spending a whole weekend working on it and try to get as far as you can.

  5. #5
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    478
    Quote Originally Posted by Elkvis View Post
    C# and VB are totally different. they use the same library (.Net runtime), but that's about where the similarities end. I'd suggest a good C# book or online tutorial to get you going. try spending a whole weekend working on it and try to get as far as you can.
    If you mean to say that the their syntaxes are insanely different, then you are right on that part. Otherwise, you are completely wrong.

    Everything you can do in VB(Assuming VB.NET) can be done in C# and the other way around. The code will be similar in structure(Not syntax, though) and in some cases almost identical, except from the trailing semi-colon.

    Of course, I'm not saying the languages are alike, but if you call yourself a C# programmer and you still can't translate a program from VB.NET to C#, you should consider taking a few more classes.
    "What's up, Doc?"
    "'Up' is a relative concept. It has no intrinsic value."

  6. #6
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Ok here is a base to get you started. You will have to add the logic for the + overload, as well as proper bounds checking.

    Code:
        class Time
        {
            //Provide some bounds checking in set for being greater then 59...
            public int Hours { get; set; }
    
            public int Minutes { get; set; }
    
            public int Seconds { get; set; }
    
            public Time()
            {
                Hours = 12;
                Minutes = 0;
                Seconds = 0;
            }
    
            public Time(int Hours, int Minutes, int Seconds)
            {
                this.Hours = Hours;
                this.Minutes = Minutes;
                this.Seconds = Seconds;
            }
    
            public static Time operator+(Time ToAdd)
            {
                //Add ToAdd to a new instance of Time and return it.
    
                return null; //Take this out...
            }
    
            public override string ToString()
            {
                StringBuilder RetString = new StringBuilder();
    
                RetString.Append(Hours.ToString().PadLeft(2, '0') + ":" + Minutes.ToString().PadLeft(2, '0') + ":" + Seconds.ToString().PadLeft(2, '0'));
    
                return RetString.ToString();
            }
        }

  7. #7
    Registered User
    Join Date
    Oct 2006
    Posts
    2,588
    Quote Originally Posted by IceDane View Post
    If you mean to say that the their syntaxes are insanely different, then you are right on that part. Otherwise, you are completely wrong.
    you're quite welcome to disagree with me, but I thought it was pretty clear that the syntax was the aspect to which I was referring. it would be pretty ridiculous to say that the two languages are the same except for syntax, since syntax is what makes a language what it is.

    Everything you can do in VB(Assuming VB.NET) can be done in C# and the other way around.
    I'm not disputing that here. the point was that the languages themselves are completely different, and that the only thing they truly share in common is their runtime library, which I stated explicitly.

    The code will be similar in structure(Not syntax, though) and in some cases almost identical, except from the trailing semi-colon.
    programming languages that use the familiar function-call syntax:

    Code:
    returnvalue = function(parameter)
    far outnumber the ones that do not, so it's not really much of a similarity.

    Of course, I'm not saying the languages are alike, but if you call yourself a C# programmer and you still can't translate a program from VB.NET to C#, you should consider taking a few more classes.
    But the OP does not call him/herself a C# programmer, and freely admitted having no knowledge of C#. therefore, it will be impossible, without a significant investment of time and effort, to perform the task of converting from VB.

    My additional suggestion to the OP is to write the program in VB, and then use readily-available software to convert it to C#. there are programs out there that will de-compile your assembly to whatever .Net language you choose. you can then compare the two and you'll begin to see how to do the things in C# that you already know how to do in VB.

  8. #8
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Frankly this assignment is trivial in any language that supports some kind of OOP environment if you have programmed before. Trivial after spending a few minutes at some online tutorials/FAQ's. The deeper problem i think is the OP doesn't have any knowledge of programming at all and has been placed in a situation that it is required.

  9. #9
    Registered User
    Join Date
    Oct 2006
    Posts
    2,588
    Quote Originally Posted by dropper166 View Post
    im in college computer technician course and our teacher gave us an assignment in C# so we can refresh our mind from highschool programming ( doesnt make anysense to me. im taking computer technician and i have to study prograaming?!). unfortunately, i didnt take any programming in highschool.
    is this likely to be the only programming related assignment for this course? if so, it might just be more expedient for someone to write the code for you (possibly for a fee). if you choose to learn more about programming later on, you have that option, and I highly recommend it.

  10. #10
    Registered User
    Join Date
    Feb 2009
    Posts
    4
    thanks for all your help guys... i have not done my assignment yet and it is due tomorrow.
    i am not the only one who having trouble with this programming course(im having fun now though) so all of us helping each other and still do not know how to make it lol. i have bought a introduction to c# programming book. i hope this will help me a lot.
    next semester we will have another programing course called xhtml some people says it fun to play with that language because you can make a website out of it.

    again, thank you, guys!

    cheers!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 05:01 PM
  2. Sending an email in C program
    By Moony in forum C Programming
    Replies: 28
    Last Post: 10-19-2006, 11:42 AM
  3. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 03:33 PM
  4. class TIME, help please
    By The-Saint in forum C++ Programming
    Replies: 5
    Last Post: 11-27-2002, 12:22 PM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 02:30 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21