Java

Moderators: zibadian
Number of threads: 7836
Number of posts: 18235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
please help me.. i need inheritance codes please Posted by Black_Joker on 14 Jan 2012 at 9:29 AM
please i need help D:

i need Inheritance codes~~~
i need to draw cars and trucks and background with road and a house with sky.

i have to use Vehicle class as a parent class. To draw pictures, i should draw fun things coming up with different drawings. the problem is that it is a "hard code".
i need to create a car class and a truck class as a children of Vehicle class.
the following UML classes shows the required elements in each class:

_________________________________
Vehicle class contains:
--------------
-x:int
-y:int
-color: Color
--------------
+Vehicle(in x:int, in y:int, in c:Color)

>>> Vehicle class to represent an aoutomobile. there are 2 types of automobile: "car" and "truck". the draw method uses these values to draw the corresponding object.
>>> the draw() method is responsible of all the drawings of the Vehicles. it contains all the logic for drawing.

_________________________________

Car Class Contains:
-----------------------
-doors: int
-----------------------
+draw(in g:Graphics)
+Car(in x: int, in y: int, in c c:Color, in d: int)
+move()

>>> the move() methods move the car across the screen. it simply update the position of the car.
_________________________________

Truck Class Contains:
--------------------
-type: string
--------------------
+move()
+draw(in g: Graphics)
+Truck(in x: int, in y: int, in c:Color, in type: string)
_________________________________

DrawPanel Class Contains:
-------------------------
+paintComponent(in g: Graphics)

>>> the drawpanel class should contain Timer object that is responsible of making things move of all Vehicles that i create.
_________________________________

TestDraw class contains nothing its only runs the classes :)
_________________________________


Finally, i need to make the vehicles exit the screen in one side they appear from the other side.
please i would like to know which codes should be in each class and i will be really thankful to you.

i hope to get the solutions as soon as possible please....




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.