public int updateGradebook(Gradebook gradebook) {
   SQLiteDatabase db = this.getWritableDatabase();
   ContentValues values = new ContentValues();
   values.put(GRADETYPE, gradebook.getgrade_type());
   if (gradebook.getparameters() != null) updateParameters(gradebook.getparameters());
   return db.update(
       TABLE_GRADEBOOK, values, C_ID + "= ?", new String[] {String.valueOf(gradebook.getcid())});
 }
 // Adding a Gradebook
 public void addGradebook(Gradebook gradebook) {
   SQLiteDatabase db = this.getWritableDatabase();
   ContentValues values = new ContentValues();
   values.put(C_ID, gradebook.getcid());
   values.put(GRADETYPE, gradebook.getgrade_type());
   db.insert(TABLE_GRADEBOOK, null, values);
   db.close();
   addParameters(gradebook.getparameters());
 }
Ejemplo n.º 3
0
  public static void main(String[] args) {

    Gradebook gb = new Gradebook();
    gb.addStudent(new GradStudent("Bob", 99.0));
    gb.addStudent(new UndergradStudent("Jane", 85.0));
    gb.displayStudents();

    // This is possible. We cannot call rentCar on s, tho.
    Student s = new GradStudent("Bob", 99.0);

    // This invokes the GradStudent version of toString because of dynamic binding.
    s.toString();

    // We can change the type of object that s refers to as long as it is in the Student
    // hierarchy.
    s = new UndergradStudent("Jane", 85.0);
  }
 // Getting course's Gradebook
 public Gradebook getGradebok(int cid) {
   String selectQuery = "SELECT * FROM Gradebook" + " WHERE cid = " + cid;
   SQLiteDatabase db = this.getWritableDatabase();
   Cursor cursor = db.rawQuery(selectQuery, null);
   cursor.moveToFirst();
   Gradebook gradebook = new Gradebook();
   gradebook.setgrid(cursor.getInt(0));
   gradebook.setcid(cursor.getInt(1));
   gradebook.setgrade_type(cursor.getString(2));
   gradebook.setparameter(getParameters(gradebook.getcid()));
   gradebook.setgrade(getGrades(gradebook.getcid()));
   return gradebook;
 }
 public void deleteGradebook(Gradebook gradebook) {
   SQLiteDatabase db = this.getWritableDatabase();
   db.delete(TABLE_GRADEBOOK, C_ID + "=?", new String[] {String.valueOf(gradebook.getcid())});
   db.close();
   deleteParameters(gradebook.getparameters());
 }