Bike Project
2-1 Practice
Get JP bikeproject.zip from Oracle Academy (or clone from https://github.com/profvanselow/BikeProjectOOP)
Import / Create project in IDE.
Analyze code and review vocabulary: primitive type, field, class, concatenation, object, constructor, inheritance
VCS -> Git -> Import into Version Control -> Share Project on GitHub
2-2 Practice
Practice Import from Version Control
VCS -> Git -> Branches -> New Branch -> 2-2
interface BikeParts
interface MountainParts
interface RoadParts
Bike implement BikeParts
MountainBike implement MountainParts
RoadBike implement RoadParts
Commit and Push
2-3 Practice
Practice Pull
VCS -> Git -> Branches -> New Branch -> 2-3
Bike abstract
printDescription -> toString
Commit and Push
3-1 Practice
VCS -> Git -> Branches -> New Branch -> 3-1
BikeUses enum
Use enum for terrain
Commit and Push
3-2 Practice
VCS -> Git -> Branches -> New Branch -> 3-2
ArrayList named bikes
mountainBikeSales and roadBikeSales
method fillArray
method displayStock
method displayBikeNumbers
Commit and Push
Database Integration
Adding a Database, Table, and Data
CREATE TABLE Bike ( make varchar(255), handleBars varchar(255), frame varchar(255), tyres varchar(255), seatType varchar(255), numGears int );
INSERT INTO Bike (make, handleBars, frame, tyres, seatType, numGears) VALUES ('Oracle Cycles', 'drop', 'tourer', 'semi-grip', 'comfort', 14);
Read from table to populate list / TableView
private void loadBikeList() throws SQLException {
String sql = "SELECT * FROM Bike";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
// these lines correspond to the database table columns
String make = rs.getString(1);
String hb = rs.getString(2);
String frame = rs.getString(3);
String type = rs.getString(4);
String seat = rs.getString(5);
Integer numGears = rs.getInt(6);
// create object
Bike bikeFromDB = new MountainBike(hb, frame, "tires", seat, numGears, "susp", type, 29);
// save to observable list
bikes.add(bikeFromDB);
}
}