Results 1 to 3 of 3
  1. #1
    ZeraX is offline Member
    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Default Having a trouble Making a program

    Hello everyone

    I'm really sorry if i'm posting in the wrong section, couldn't figure out the right place

    i'm doing some program about bicycles for the university..
    and asked as follows:
    Write a TestBikes Main Class that will declare array of bikes of type Bicycle of size 6. Fill it with 6 objetcs of different types that the user will decide. Allow the user to speed up or slow down the speed of any object of his/her choice. Allow the user to get or set any attribute of any object of his/her choice. The attributes of these objects are entered by the user. Then, print the description of all bikes.
    i made all the classes, i just don't know how to make the main method properly, here is my code:


    import java.util.*;

    abstract public class Bicycle {



    protected int startCadence;
    protected int startSpeed;
    protected int startGear;

    public Bicycle (int startCadence,int startSpeed, int startGear){
    this.startCadence = startCadence;
    this.startSpeed = startSpeed;
    this.startGear = startGear;
    }

    public int getStartCadence() {
    return startCadence;
    }

    public void setStartCadence(int startCadence) {
    this.startCadence = startCadence;
    }

    public int getStartGear() {
    return startGear;
    }

    public void setStartGear(int startGear) {
    this.startGear = startGear;
    }

    public int getStartSpeed() {
    return startSpeed;
    }

    public void setStartSpeed(int startSpeed) {
    this.startSpeed = startSpeed;
    }

    public void applyBrake(int slower){
    //will decrement the speed by slower
    }

    public void speedUp(int faster){
    //) will increment the speed by faster
    }
    public void printDescription(){
    System.out.println("Bike is in gear this.gear with a caence of this.cadence and travelling at a speed of this.speed");
    }
    }

    public class RoadBike extends Bicycle{

    private int tireWidth;

    public RoadBike(int tireWidth, int startCadence, int startSpeed, int startGear) {
    super(startCadence, startSpeed, startGear);
    this.tireWidth = tireWidth;
    }

    public int getTireWidth() {
    return tireWidth;
    }

    public void setTireWidth(int tireWidth) {
    this.tireWidth = tireWidth;
    }

    public void printDescription(){

    }
    }

    public class MountainBike extends RoadBike{

    private String suspension;
    private int seatHeight;

    public MountainBike(String suspension, int seatHeight, int tireWidth, int startCadence, int startSpeed, int startGear) {
    super(tireWidth, startCadence, startSpeed, startGear);
    this.suspension = suspension;
    this.seatHeight = seatHeight;
    }

    public int getHeight() {
    return seatHeight;
    }

    public void setHeight(int seatHeight) {
    this.seatHeight = seatHeight;
    }

    public String getSuspension() {
    return suspension;
    }

    public void setSuspension(String suspension) {
    this.suspension = suspension;
    }
    public void printDescription(){


    }




    }
    main class
    package assignment_3;

    import java.util.Scanner;


    public class TestBikes {
    public void main (String [] args){

    Scanner scan = new Scanner (System.in);
    String[]ar = new String [6];
    }
    }

    as you see i'm not good at connecting classes and using them in the main class


    much appreciated any help and thank you :)

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,422
    Rep Power
    20

    Default Re: Having a trouble Making a program

    Use code tags, not quote tags, for posting code.

    Guide For New Members
    BB Code List - Java Programming Forum

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,422
    Rep Power
    20

    Default Re: Having a trouble Making a program

    Moved from NetBeans.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. JFileChooser making trouble while passing the file path
    By raj.mscking@gmail.com in forum New To Java
    Replies: 2
    Last Post: 06-08-2012, 04:45 AM
  2. Trouble making graphics display
    By quinnvanorder in forum New To Java
    Replies: 6
    Last Post: 02-05-2012, 07:39 AM
  3. Making a program.
    By Headlessmunky in forum New To Java
    Replies: 11
    Last Post: 08-23-2011, 07:18 PM
  4. Making a map program
    By cchase88 in forum AWT / Swing
    Replies: 1
    Last Post: 12-05-2010, 11:01 PM
  5. Making the program
    By pheonix in forum Advanced Java
    Replies: 4
    Last Post: 04-18-2009, 07:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •