spertuit's Profile User Rating: -----

Reputation: 0 Apprentice
New Members
Active Posts:
6 (0.01 per day)
02-February 13
Profile Views:
Last Active:
User is offline Feb 02 2013 01:30 PM

Previous Fields

Dream Kudos:
Icon   spertuit has not set their status

Posts I've Made

  1. In Topic: Need a little help understanding objects

    Posted 2 Feb 2013

    Pointer, makes sense now.
    Thanks for all your help. I'm finally getting to the point with Objective-C where I can manipulate the data and get some feedback displaying. Hopefully by tonight I can write a program with a little complexity.
  2. In Topic: Need a little help understanding objects

    Posted 2 Feb 2013

    Excellent reply, I ran through your code and understood all of it except one part is a little cloudy to me.
    The variable car in mechanic. The idea of this variable is not actually any type of link to the object but more like
    an ID in a database, if I'm making sense.

    For instance if I did a loop statement and would increment i
    Than I would say car = i, and than would call car.reduceWeightOfCar(500)
    In this case if the objects of the Car class would be 1,2,3,etc
    This would perform the weight reduction to all the objects, but your code maintains encapsulation by keeping the variables private.

    I know that's a little sloppy, but I'm just trying to wrap my head around the logic. I'm currently working in Objective-C, my background is strong in web development.(PHP)
  3. In Topic: Need a little help understanding objects

    Posted 2 Feb 2013

    View Postmodi123_1, on 02 February 2013 - 11:22 AM, said:

    You may be getting lost in the words to objects. Sometimes that doesn't translate to a hard line.

    As I said there are multiple ways to set this up (and it depends on how they will be used), but in general you would have a car object... which has variables, properties, and methods.

    Then you would have a mechanic object. A mechanic object would have a car variable... because a mechanic can only work on one car at a time. The mechanic then has methods like 'do oil chance' or 'fix unicorns poking holes in the exhaust' and so forth... but it needs a car object to do that.

    I see what you mean now. It basically depends on if the program is based off the actions of the mechanic or if it is based off the car.
  4. In Topic: Need a little help understanding objects

    Posted 2 Feb 2013

    View PostRyano121, on 02 February 2013 - 11:04 AM, said:

    You would probably have a mutator method in the Car class to reduce the weight of the car by a certain amount e.g

    public void reduceWeight(int howMuch) {
       weight = weight = howMuch;

    Then you have a method in the Mechanic class to perhaps reduce the weight of a car

    public void reduceWeightOfCar(Car car) {
        // some logic here to determine how much to reduce it by

    Now you could just make the weight attribute public so it's accessible to anyone, but thats bad design as anyone can change it's value anywhere. You can see here that I could put a check in the reduceWeight method to check if I will be reducing it by more than its current weight which of course is not possible. I could then produce an error if this happened. Making the field public however you could not do these checks to keep the integrity of the attribute. This is encapsulation - one of the founding ideas of object oriented programming.

    So really you have a method in the Car class to do something to the attribute of the Car, you then allow other classes (i.e the Mechanic) to use this method to do something.

    I think I've gone off in a bit of a tangent here, but I hope I've answered your question.

    This would mean that the method in the mechanic class is the "getter", or the "
    accessor" and the method in the car class is the "setter". This keeps the integrity of the encapsulation.
    Am I on the right track?
  5. In Topic: Need a little help understanding objects

    Posted 2 Feb 2013

    I'm going to research "mutator methods". I had the understanding that methods where actions the object could perform. This throws off my thinking. The reduction is something being done to the car, so this is an action being formed to the object.
    I'll pick apart your post and research each part to understand this more.

    I appreciate the detailed response. I am very skilled in procedural coding, but for some reason I'm having a difficult time grasping object oriented.

    View Postmodi123_1, on 02 February 2013 - 11:06 AM, said:

    In theory - yeah. Either your program is the 'mechanic' class and it operates/interacts with the object, or you build a mechanic class that has a 'car' property.

    I'm lost on the idea of giving the mechanic a car property. The mechanic would be manipulating the "Car" object. Would you somehow tie the property "car" of the mechanic to the instanced object of the "Car" class?

My Information

Member Title:
New D.I.C Head
Age Unknown
Birthday Unknown

Contact Information



spertuit hasn't added any friends yet.


spertuit has no profile comments yet. Why not say hello?