Bike Project

2-1 Practice

  1. Get JP bikeproject.zip from Oracle Academy (or clone from https://github.com/profvanselow/BikeProjectOOP)

  2. Import / Create project in IDE.

  3. Analyze code and review vocabulary: primitive type, field, class, concatenation, object, constructor, inheritance

  4. VCS -> Git -> Import into Version Control -> Share Project on GitHub

2-2 Practice

  1. Practice Import from Version Control

  2. VCS -> Git -> Branches -> New Branch -> 2-2

  3. interface BikeParts

  4. interface MountainParts

  5. interface RoadParts

  6. Bike implement BikeParts

  7. MountainBike implement MountainParts

  8. RoadBike implement RoadParts

  9. Commit and Push

2-3 Practice

  1. Practice Pull

  2. VCS -> Git -> Branches -> New Branch -> 2-3

  3. Bike abstract

  4. printDescription -> toString

  5. Commit and Push

3-1 Practice

  1. VCS -> Git -> Branches -> New Branch -> 3-1

  2. BikeUses enum

  3. Use enum for terrain

  4. Commit and Push

3-2 Practice

  1. VCS -> Git -> Branches -> New Branch -> 3-2

  2. ArrayList named bikes

  3. mountainBikeSales and roadBikeSales

  4. method fillArray

  5. method displayStock

  6. method displayBikeNumbers

  7. Commit and Push

Database Integration

Video Series

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);

}

}