update
parent
d130aa4525
commit
9e597946c2
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.mp4_calebfontenot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class BikeStores
|
||||
{
|
||||
ArrayList<ArrayList<Bicycle>> storesOfBikes = new ArrayList<ArrayList<Bicycle>>();
|
||||
/**Add a bike at storeNumber ( i.e. the storeNumber indicates the store)
|
||||
*
|
||||
* @param storeNumber which store
|
||||
* @param b the bike to add
|
||||
* @return true if the bike added, false if the storeNumber is invalid or b is null.
|
||||
*/
|
||||
public boolean addBike( int storeNumber, Bicycle b)
|
||||
{
|
||||
//to be implemented
|
||||
return false;
|
||||
|
||||
}
|
||||
/** Removes a bike at a specific store.
|
||||
*
|
||||
* @param store the store that has the bike
|
||||
* @param bthe bike to be removed
|
||||
* @return true of the bike is removed, false if the bike does not exist, or bike is null.
|
||||
*/
|
||||
|
||||
public boolean removeBike( int store , Bicycle b)
|
||||
{
|
||||
//to be implemented
|
||||
return false;
|
||||
}
|
||||
/**Prints the indexes before each bike , one store per line
|
||||
*
|
||||
* @param stores stores of bikes
|
||||
*/
|
||||
public static void printAllStores( ArrayList<ArrayList<Bicycle>> stores)
|
||||
{
|
||||
|
||||
for ( int i=0; i < stores.size(); ++i)
|
||||
for ( int j=0; j < stores.get(i).size(); ++j)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
/** Groups bikes by type ans sorts them by the ranking of Details.
|
||||
* There will be three groups and each group stored in decending order by rank.
|
||||
* @param stores the stores of bikes
|
||||
* @return a newly created ArrayList<ArrayList<Bicycle>> with the bikes sorted.
|
||||
*/
|
||||
public ArrayList<ArrayList<Bicycle>> sortBikesByType( final ArrayList<ArrayList<Bicycle>> stores)
|
||||
{
|
||||
ArrayList<ArrayList<Bicycle>> newStore = new ArrayList<ArrayList<Bicycle>>();
|
||||
|
||||
return newStore;
|
||||
}
|
||||
/**
|
||||
* Returns a 2D array containing all the bikes in the store in proper sequence (from first to last element). Store 0 with all its bikes, store 1 with all its bikes, and so on.
|
||||
* @return a 2D array of all stores with bikes.
|
||||
*/
|
||||
public Object[][] toArray() {
|
||||
//a.toArray();
|
||||
}
|
||||
/**
|
||||
* Retains only the Bicycles in the stores that are contained in the specified collection. In other words, removes from this list all of bikes that are not contained in the specified location.
|
||||
* @param c the bikes to be removed
|
||||
* @return true if any store changed as a result of the call.
|
||||
*/
|
||||
public boolean retainAll (Collection<Bicycle> c) {
|
||||
|
||||
}
|
||||
public static void main(String[] args)
|
||||
{
|
||||
BikeStores bikes = new BikeStores();
|
||||
//add 5 bikes to store 0 ( 2 speedBikes, 2 mountain 1 child)
|
||||
bikes.addBike(0, new SpeedBike(4, 3, 10, 40));
|
||||
bikes.addBike(0, new SpeedBike(1, 2, 10, 30));
|
||||
bikes.addBike(0, new MountainBike(1, 2, 3, 20));
|
||||
bikes.addBike(0, new MountainBike(3, 2, 10, 25));
|
||||
bikes.addBike(0, new ChildBike(false, 1, 1, 10));
|
||||
//add 5 bikes to store 1 ( 3 speedbikes, 1 mountain 1 child)
|
||||
bikes.addBike(1, new SpeedBike(10, 4, 10, 20));
|
||||
bikes.addBike(1, new SpeedBike(0, 2, 10, 50));
|
||||
bikes.addBike(1, new SpeedBike(3, 2, 10, 38));
|
||||
bikes.addBike(1, new MountainBike(1, 3, 5, 44));
|
||||
bikes.addBike(1, new ChildBike(true, 1, 1, 15));
|
||||
//add 6 bikes to store 2 ( 2 speedBikes, 2 mountain 2 child )
|
||||
bikes.addBike(2, new SpeedBike(7, 10, 20, 25));
|
||||
bikes.addBike(2, new SpeedBike(0, 8, 40, 55));
|
||||
bikes.addBike(2, new MountainBike(2, 3, 15, 33));
|
||||
bikes.addBike(2, new MountainBike(1, 3, 15, 24));
|
||||
bikes.addBike(2, new ChildBike(true, 1, 2, 20));
|
||||
bikes.addBike(2, new ChildBike(false, 1, 1, 18));
|
||||
//remove one child bike from store 2
|
||||
//PRINT
|
||||
//SORT
|
||||
//PRINT what the method return
|
||||
//PRINT the original store
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class NotABike{
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.mp4_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class ChildBike extends Bicycle //remove comment in front or extends
|
||||
{
|
||||
|
||||
private boolean helpWheels;
|
||||
|
||||
public ChildBike(boolean helpWheels, int cadence, int gear, int speed)
|
||||
{
|
||||
super(cadence, gear, speed);
|
||||
this.helpWheels = helpWheels;
|
||||
}
|
||||
|
||||
public boolean isHelpWheels()
|
||||
{
|
||||
return helpWheels;
|
||||
}
|
||||
|
||||
public void setHelpWheels(boolean helpWheels)
|
||||
{
|
||||
this.helpWheels = helpWheels;
|
||||
}
|
||||
|
||||
@Override
|
||||
Details calculatedDetails()
|
||||
{
|
||||
return Details.getDetails(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return super.toString() + "ChildBike{" + "helpWheels=" + helpWheels + '}';
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue