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.

Results 1 to 4 of 4

Thread: Need help with A school project!

  1. #1
    Junior Member
    Join Date
    Oct 2017
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need help with A school project!

    Create a class called Bike that inherits the Vehicle class.
    Create a class called MotorBike that inherits the Bike class.
    Overide the toString of the Bike, and MotorBike class
    The Bike class should have overloaded constructors, at least two.
    The Bike class should override at least on method.
    Create multiple objects of the MotorVehicle class and populate them with data.
    The data should captured from a panel constructed using JFrame, and JPanel.


    I have created, a bike class that extends vehicle and I created MotorBike that extends Bike.
    That’s about all I know how to do. Any help would be cool thanks

  2. #2
    Member John Joe's Avatar
    Join Date
    Jun 2017
    Posts
    277
    My Mood
    Amused
    Thanks
    8
    Thanked 19 Times in 19 Posts

    Default Re: Need help with A school project!

    please post the code you have tried
    Whatever you are, be a good one

  3. #3
    Junior Member
    Join Date
    Oct 2017
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help with A school project!

    Quote Originally Posted by John Joe View Post
    please post the code you have tried
    Sure thing.

    public class Vehicle {
    String Make;
    String Modle;
    int TopSpeed;
    int Miles;
    String Name;

    public String getMake() {
    return Make;
    }


    public class MotorBike extends Bike {
    private String Make = ("Honda");
    private String Modle = ("CBR");
    private int TopSpeed = (150);
    private int Miles = (25000);
    private String Name = ("Betty");

    @Override
    public String toString() {
    return "MotorBike{" + "Make=" + Make + ", Modle=" + Modle + ", TopSpeed=" + TopSpeed + ", Miles=" + Miles + ", Name=" + Name + '}';
    }

    public static void main(String[] args) {

    }
    }

    public class Bike extends Vehicle {

    public Bike() {
    String Make = ("GT");
    String Modle = ("Mach One Pro 24");
    int TopSpeed = (15);
    int Miles = (1000);
    String Name = ("Old Fathful");
    }

    @Override
    public String toString() {
    return "Bike{" + "Make=" + Make + ", Modle=" + Modle + ", TopSpeed=" + TopSpeed + ", Miles=" + Miles + ", Name=" + Name + '}';
    }

    public static void main(String[] args) {

    }
    }



    Thanks again for any help.


    public void setMake(String Make) {
    this.Make = Make;
    }

    public String getModle() {
    return Modle;
    }

    public void setModle(String Modle) {
    this.Modle = Modle;
    }

    public int getTopSpeed() {
    return TopSpeed;
    }

    public void setTopSpeed(int TopSpeed) {
    this.TopSpeed = TopSpeed;
    }

    public int getMiles() {
    return Miles;
    }

    public void setMiles(int Miles) {
    this.Miles = Miles;
    }

    public String getName() {
    return Name;
    }

    public void setName(String Name) {
    this.Name = Name;
    }


    public static void main(String[] args) {

    Vehicle B1=new Vehicle();
    Vehicle MB=new Vehicle();





    }
    }

  4. #4
    Member John Joe's Avatar
    Join Date
    Jun 2017
    Posts
    277
    My Mood
    Amused
    Thanks
    8
    Thanked 19 Times in 19 Posts

    Default Re: Need help with A school project!

    Where is your MotorVehicle class ? And the code after "Thanks again for any help." is belongs to which class ?
    Whatever you are, be a good one

Similar Threads

  1. Java School Project Help; Project #2, In Danger of Failing.....
    By john++ in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 2nd, 2014, 02:35 AM
  2. School project
    By midnight21 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 21st, 2013, 03:48 PM
  3. [SOLVED] Help with school project
    By mattisvan in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 15th, 2013, 07:22 AM
  4. [SOLVED] Why do I need more than 1 class? - School project help.
    By Kakihara in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 26th, 2012, 09:08 PM
  5. school project
    By robin28 in forum Java Theory & Questions
    Replies: 13
    Last Post: November 12th, 2010, 09:11 AM

Tags for this Thread