Wednesday, December 23, 2009

Can someone give me an example of how one would program in object oriented programing?

My teachers given a very abstract lesson using ideas that could apply to anything. If I were to program in this way what would I use and do?Can someone give me an example of how one would program in object oriented programing?
Object oriented programming is very simple. You program each class (object) separately, and initialise and call them using methods. This way, you can develop the program in parallel, and minimise debug time.





An example would be making a game. One can program a generic character class, another generic dungeon class, another generic monster class, another making the main class which initialise on all other classes to make the game.





Code-wise, here's an example. This is java, so bear with it for a sec:D





public class Student{


variables


constructor


methods


}





public static void main (String arg[]) throws IOException{


variables


Student lol = new Student(); //instantiate a student object





constructor


methods


}
  • beauty treatments
  • car oil
  • No comments:

    Post a Comment