Jump to content

someboddy

Ultra Members
  • Posts

    1,661
  • Joined

  • Last visited

Everything posted by someboddy

  1. The guy must be a realy good modeller
  2. for(k=1;k <= 1;k--) I know this code is inside a comment, but it is still an endless loop. Yea, I know, eventualy k will cross the minimum line for integers and become a positive number(or throw an exception. I never tried it on JAVA), but this is still bad programing. public Mac(Graphics g, int x, int y, int w, int h) ... speakers = new Speakers(g,x,y,w,h); And class Speakers extends Mac ... public Speakers(Graphics g,int x,int y,int w,int h) { super(g,x,y,w,h); Wrong wrong wrong. This is called endless recursion. When a Mac is created, it creates a new Speaker. Speaker extends Mac, and has a super call in it's constructor, therefore another Mac constructor is called, which creates another Speaker, which is Mac, so it creates another Speaker, and so on until you run out of memory. There is another issue. You create new instances on every paint, when you can use the same ones over and over. I never realy worked with applets, but I belive they have an initialization method. Create an instance of the Mac there, and call the paint methods on the paint function. import java.util.Random; import java.util.*; This is not realy a problem, only a style issue. When you inport java.util.*, java.util.Random is imported as well, so you don't need to import him specifically. If you want the reader of the code to know you have a special interest in the Random class, write it in a comment. That's why you have them. Also, I suggest using colors for the different parts of your Mac.
  3. Do not fear, someboddy is here! I suppose you only have one lab per week, so I'm not too late. I will not write all the setters and getters. Only the important stuff. Lets say we have a class Person: public class Person { private String id; private String name; private int age; public Person(String id,String name,int age) { this.id=id; this.name=name; this.age=age; } public String toString() { return "name:"+name+"\nid:"+id+"\nage:"+age; } } Now, lets create a Student class inheriting Person: public class Student extends Person { private String university; private int year; public Student(String id,String name,int age,String university,int year) { super(id,name,age); this.university=university; this.year=year; } public String toString() { return super.toString()+"\nyear number "+year+" at "+university; } } Now, since I hate to work hard, I will mix the second example of inheritance with one of the composition levels. We will have a MarriedPerson class: public class MarriedPerson extends Person { private Person marriedTo; public MarriedPerson(String id,String name,int age,Person marriedTo) { super(id,name,age); this.marriedTo=marriedTo; if(marriedTo instanceof MarriedPerson) ((MarriedPerson)marriedTo).marriedTo=this; } public String toString() { return super.toString()+"\nmarried to "+marriedTo.getName(); } } Now, note that if I'd wrote in the toString function return super.toString()+"\nmarried to "+marriedTo.getName(); and marriedTo is an instanceof MarriedPerson, the function will cause an endless recursion. ---------------------------------------------------------------------------- About the other level of composition, we will have a Point2D class and a Circle class Here is the Point2D class: public class Point2D { private double x; private double y; public Point2D(double x,double y) { this.x=x; this.y=y; } public Point2D(Point2D source)//copy constructor { this(source.x,source,y) } } And here is the Circle class: public class Circle { private Point2D center; private double radius; public void setCenter(Point2D center) { if(center!=null) this.center=new Point2D(center); } public Circle(Point2D center,double radius) { setCenter(center); this.radius=radius; } } Thats it, nice and simple. --------------------------------------------------------------------------- I know you are only at the beginning of learning JAVA, but when you feel experienced enough to program games, feel free to try jmonkeyengine.com. You might also find help in gamedev.net's forums. And for the next time, D O - Y O U R H O M E W O R K Y O U R S E L F
  4. Castlevania-Curse of Darkness(Worst castlevania name ever, but the game is nice).
  5. Another reason not to be French...
  6. Yea, too bad there are no swordfights in the game. Ryu has a sword, and Kasumi has a dagger, but they don't use it in the game.
  7. For those of you who haven't seen the trailer to the upcoming Dead or Alive movie yet, here is the link. It's not a new thing that DOA is underrated and treated as a provocative game that otherwise sucks. But even those who think that way have to agree - this is a new low. This looks like the worst game based movie ever. So, someone decided to make a petition to the companies responsible to that film. He posted a topic about it in gamefaqs, so I want to bring this to your attention. here is the link to the petition
  8. Topic speak for itself
  9. "They"? I thought only you call yourself LoveCop
  10. PS2 owners gets everything. Nothing for XBoxers
  11. Moved to the PSP forum.
  12. While making the game, I noticed the player can stay in one location and just press the shooting button, and he will never die, because he shoot all the crap that falls on him. So I made the crap move when other crap falls on it, so you will have to do some footwork and to make a good use out of blue baloons.
  13. This is my first game in java. It is fairly simple. Tell me what you think. http://www.geocities.com/someboddysflyingcows/
  14. My advice to you is that: don't play pokemon games
  15. This game is cool. Now you can take the enemies weapons and use them like in Kirby.
  16. I do - HALLELUYA
  17. Kim Kaphawn form KoF Ryu Hayabusa and Ein from Dead or Alive
  18. Wow. I never knew I know portuguese...
  19. It will be hack-proof, if M$ will make it explode when someone tries to open it.
  20. I hope he just don't have internet right now.
  21. Gryphon, promise me you won't die.
  22. Maby he can reflect bullets with his sword?
  23. Do you realize how gay this sounded?
×
×
  • Create New...