Hi all.. I wish that u cake hlp me plllzzzzzzzzzzzz,, don't solve for me ,,,just teach me how to make it !!!! Plz I'll wait for some Volunteer
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi all.. I wish that u cake hlp me plllzzzzzzzzzzzz,, don't solve for me ,,,just teach me how to make it !!!! Plz I'll wait for some Volunteer
Hello Faha,
Welcome to the forums.
We are always willing to help, but you have not asked a question?
Please give us a solid description of your problem and incude as much code as possible.
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.
Ok it's all about to create 4 class
Class a , class b derived from a and c derived from b and test class
Speed is an instance variable in class b and c.
The method are :
Start() -a method of all class to print the message"hee" override the method in class b and c to print ""hoo" and "hmm" correspondingly
Stop() -a method of class a to print a message"cool" override the method in class b and c to print the "stop"and "stop c" correspondingly
Setspeed() -a method of class b and c to set the value of speed with the value passed to the method .make sure that maximum speed allowed for class b is 75 km/h .if the value to be assigned to speed is more than that assign 75 to E and print the message "over". Similarly the maximum speed for class c is 200 km/h the same for class c
Getspeed(). - a method of class b and c return speed
Increasespeed(). -a method of class b and c .increase the speed with the given value make sure that if the increased value of speed more than 75 km/h for class b then set speed to 75 and print message" neew" dobthe same for class c print the new speed
Write a test class in java and let the user to chose the shape by displaying a menu like below:
1.a
2.b
3.c
4.exit
If the user enter 1 create an instance of class a and call all the method of class a. And make it the same with class b and c call the method in the same class when he chose 4 stop then terminate the program
Make the user to enter their choices repeatedly (use loop) until they press 4 to exit
People won't complete an assignment for you.
Please start to write some code, post what you have and we can take it from there..
We are happy to help just as long as you show some effort on your part. Thank you.
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.
Since it appears that the methods getSpeed() and setSpeed(int speed) are both in b and c and I don't know what it's for in a, I'm gonna assume it has no use itself in a and make these methods abstract(that way b and c will each have to define them). a will be an abstract class that cannot be instantiated.
public abstract class a
{
public a(params)
{
}
// you can define stop and start (note, these won't be abstract, as it appears you do print something in the methods
// for this class
public abstract void setSpeed(int speed);
public abstract int getSpeed();
}
Wait a minute here....if c extends b, then you'd have to override b, not a.
Are you sure b and c both don't extend a?
Yss only b extends from a and other from b
Last edited by Faha; December 10th, 2010 at 01:09 PM.
ok, in that case, it's still possible for b and c to have private variable speed.
However, c is overriding the methods that it needs to in class b.
All you have to do to override a method is to use the same method name, exact parameters, and return type as the method in the super class.
For instance,
Object has a toString() that, since it doesn't really have much to go on, returns stuff that might be useful to a computer but is gibberish to us.
However, if you had, say, a class called Person that had a method called getName and getAge and getGender.
You'd do this:
public String toString()
{
String str = "The name is: " + getName() + ". The age is: " + getAge() + ". The gender is: " + getGender() + ".";
return str;
}
That just overrode the toString() method in Object, the super class, directly or indirectly, of all classes in Java.
However, doing something like below is called overloading, not overriding. The compiler won't find anything wrong with it, but it will be different from what the instructor probably wants.
public String toString(String str)
{
return str;
}
that had the same method name and return type, but a new parameter.
that overloaded, but not overrode, Object's toString().
it's best if b and c both have a private variable speed.
I'll show for one method from each class what to do
for class a
public void Start()
{
System.out.println("Hee");
}
for class B
public void Start()
{
System.out.println("Hoo");
}
Also, in class B
public void setSpeed(int speed)
{
if (speed <=75)
speed = speed;
else
speed = 75;
}
for class C
public void setSpeed(int speed)
{
if (speed <=200)
speed = speed;
else
speed = 200;
}
Ok I'll try it with my jcrater and finish all this then I will be answer you what happen
Thannnnnx for helpppppp mmeee