0% found this document useful (0 votes)
3 views15 pages

Object Oriented Programming

The document outlines a curriculum for Object Oriented Programming, detailing weekly topics such as debugging, database connections, and developing data-driven applications. It includes sections for activities, assignments, and quizzes, along with code examples for managing data in .NET applications. The content emphasizes the importance of database connections and CRUD operations in software development.

Uploaded by

Louielyn Mendoza
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views15 pages

Object Oriented Programming

The document outlines a curriculum for Object Oriented Programming, detailing weekly topics such as debugging, database connections, and developing data-driven applications. It includes sections for activities, assignments, and quizzes, along with code examples for managing data in .NET applications. The content emphasizes the importance of database connections and CRUD operations in software development.

Uploaded by

Louielyn Mendoza
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Object

Oriented
Programming

ARIENDA, MARVIN JAY M.


SBIT - 2C
Contents
Table of
01 Week 10
Debugging and Tracing

02 Week 11 - 12
Working with .NET Framework and MDI

03 Week 13
Database Connection

04 Week 14 - 15
Developing Data Driven Applications

05 Activities

06 CRUD

07 Assignments

08 Game

09 Quizzes

03
Week 10

01 02
Week 13 Week 11 - 12

07 04
05 06
Week 14 - 15

11 08
09 10
Activities
Week 10

15 12
13 14
CRUD Activities
Log book Week 11 - 12

19 16
Public Class Srch_frm

Private Sub Srch_frm_Load(sender As Object, e As EventArgs) Handles [Link]


[Link]()

[Link] = 2
[Link](0).Name = ".NET Method"
[Link](1).Name = "Description"

[Link] = [Link]

Public Class Manip_frm [Link] = New Font("Trebuchet MS", 12, [Link])


Private Sub Manip_frm_Load(sender As Object, e As EventArgs) Handles [Link] [Link] = New Font("Trebuchet MS", 12, [Link])
[Link]() [Link] = [Link](75, 59, 42)
[Link] = [Link]
[Link] = 2 [Link] = False
[Link](0).Name = ".NET Method"
[Link](1).Name = "Description" [Link] = [Link]
[Link] = [Link]
[Link] = [Link] [Link] = [Link]

[Link] = New Font("Trebuchet MS", 12, [Link]) [Link] = [Link]


[Link] = New Font("Trebuchet MS", 12, [Link]) [Link] = False
[Link] = [Link](75, 59, 42) [Link] = True
[Link] = [Link]
[Link] = False [Link]("Asc, AscW", "Returns the character code of a character.")
[Link]("Chr, ChrW", "Returns the character for a given code.")
[Link] = [Link]
[Link]("Filter", "Filters a string array based on criteria.")
[Link] = [Link]
[Link]("Format", "Formats a string based on a format expression.")
[Link] = [Link]
[Link]("FormatCurrency", "Formats a value as currency.")
[Link]("FormatDateTime", "Formats a value as date/time.")
[Link] = [Link]
[Link]("FormatNumber", "Formats a value as a number.")
[Link] = False
[Link]("FormatPercent", "Formats a value as a percentage.")
[Link] = True
End Sub
[Link]("Right", "Returns characters from the right side of a string.") End Class
[Link]("RSet", "Right-aligns a string to a specified length.")
[Link]("RTrim", "Removes trailing spaces.")
[Link]("Space", "Returns a string of spaces.")
[Link]("Split", "Splits a string into substrings.")
[Link]("StrComp", "Compares two strings (-1, 0, 1).")
[Link]("StrConv", "Converts a string as specified.")
[Link]("StrDup", "Repeats a character a specified number of times.")
[Link]("StrReverse", "Reverses the character order of a string.")
[Link]("Trim", "Removes leading and trailing spaces.")
[Link]("UCase", "Converts a string to uppercase.")
End Sub
End Class

17 18
Game

Public Class Form1 ' ==== FORM LOAD ====


Private Sub Form1_Load(sender As Object, e As
' ==== CONSTANTS ==== EventArgs) Handles [Link]
Private Const BOAT_Y As Integer = 199
Private Const GROUND_Y As Integer = 232 mario(1) = Mario1 : mario(2) = Mario2 : mario(3) =
Private Const CHARACTER_SPACING As Integer = 55 Mario3
Private Const MAX_BOAT_CAPACITY As Integer = 2 bowser(1) = Bowser1 : bowser(2) = Bowser2 : bowser(3)
= Bowser3
' ==== SHORE POSITIONS ====
[Link] = boatPosRight
Private Const LEFT_MARIO_START As Integer = 50 [Link] = BOAT_Y
Private Const LEFT_BOWSER_START As Integer = 210 [Link] = True

InitialCharacterPositioning()
Private Const RIGHT_MARIO_START As Integer = 600 UpdateUI()
Private Const RIGHT_BOWSER_START As Integer = 750 End Sub

' ==== GAME STATE ==== ' ==== INITIAL SETUP ====
Private leftM As Integer = 0, leftC As Integer = 0 Private Sub InitialCharacterPositioning()
Private rightM As Integer = 3, rightC As Integer = 3
Private boatM As Integer = 0, boatC As Integer = 0 For i = 1 To 3
Private boatLeft As Boolean = False mario(i).Left = RIGHT_MARIO_START + ((i - 1) *
CHARACTER_SPACING)
mario(i).Top = GROUND_Y - mario(i).Height
Private boatPosLeft As Integer = 370 mario(i).Visible = True
Private boatPosRight As Integer = 480 Next

Private mario(3) As PictureBox For i = 1 To 3


Private bowser(3) As PictureBox bowser(i).Left = RIGHT_BOWSER_START + ((i - 1) *
CHARACTER_SPACING)
Private marioInBoat(3) As Boolean bowser(i).Top = GROUND_Y - bowser(i).Height
Private bowserInBoat(3) As Boolean bowser(i).Visible = True
Next
End Sub

23 20
Assignments 11. How deletes in a dataset are managed when syncing with a database [Link]() marks the row as
"Deleted." The DataAdapter sends a DELETE command to the DB during Update(). AcceptChanges() finalizes
the local deletion after confirmation.

1. Why is establishing a database connection important?


12. Comparison of UpdateRowSource options None: No values update DataSet. OutputParameters: Only
Allows your application to retrieve, insert, update, or delete
output parameters update. FirstReturnedRecord: First record updates the row. Both: Uses both output
data by communicating with the database. Essential for
parameters and the first record.
accessing information.
13. How Fill decides between adding or updating If the incoming row's primary key already exists in the
2. Main features of the relational data model & why it’s widely
DataTable, Fill updates that row. If the key is new, it adds the row as a new entry.
used Data is in tables (rows/cols). Relationships defined by
Primary/Foreign Keys. Uses SQL. Widely used for its
14. Purpose of TableMapping and FillLoadOption TableMapping maps source database columns to
reliability, consistency, and strong structure.
DataTable columns when names differ. FillLoadOption controls how incoming data is stored in the
DataRow's versions (Original, Current, or both).
3. Why use consistent capitalization in SQL?
Improves readability and code style, making complex queries easier to understand and debug in large
15. Identity vs GUID for unique values Identity (Auto-increment Integer): Fast, simple, best for single-
projects.
database systems. GUID (UNIQUEIDENTIFIER): Globally unique, ideal for distributed systems
or replication.
4. Steps to add a new row to a DataTable
Create a DataRow using [Link]().
16. Reflecting on today's session, what is one key you learned about developing data-driven applications?
Assign values
I learned the critical importance of properly managing data changes (add, update, delete) to maintain
Add to table: [Link](row).
the application's accuracy and consistency.
Optionally
update the database.

5. Editing an existing row in a DataTable


Locate the row.
Change column values directly.
Use AcceptChanges() to confirm or RejectChanges() to undo.

6. Difference between committing and undoing a deletion in a


DataSet Committing: [Link]() marks the row, and AcceptChanges() removes it permanently. Undoing
RejectChanges() cancels the delete and restores the row.

7. Importance of data-driven applications Rely on real-time data to personalize user experience, automate
tasks, and make decisions, ensuring the app remains useful and relevant.

8. Steps to load data into a DataSet using OleDb in [Link]


Create and open OleDBConnection
OleDbDataAdapter with SQL. 3. Call [Link](dataset, "TableName").

9. Creating and adding a DataRow in a data-driven application. Generate a new row using NewRow(), fill all
required column values, and add it to the DataTable. This prepares it for later saving to the database.

10. How null values affect arithmetic and comparison Arithmetic involving NULL results in NULL.
Comparisons result in unknown. Use IS NULL or IS NOT NULL to check for them.

21 22
' ==== CHARACTER CLICK EVENTS ==== Private Sub RepositionBoatPassengers()
Private Sub Mario_Click(sender As Object, e As Dim passengerIndex As Integer = 0
EventArgs) _ For i = 1 To 3
Handles [Link], [Link], [Link] If marioInBoat(i) Then
mario(i).Left = [Link] + 10 + (passengerIndex *
Dim pic As PictureBox = CType(sender, PictureBox) 40)
Dim index As Integer = mario(i).Top = [Link] - mario(i).Height + 10
CInt([Link]([Link] - 1)) passengerIndex += 1
TogglePassenger(pic, marioInBoat, index) End If
End Sub Next
For i = 1 To 3
Private Sub Bowser_Click(sender As Object, e As If bowserInBoat(i) Then
EventArgs) _ bowser(i).Left = [Link] + 10 + (passengerIndex *
Handles [Link], [Link], [Link] 40)
bowser(i).Top = [Link] - bowser(i).Height + 10
Dim pic As PictureBox = CType(sender, PictureBox) passengerIndex += 1
Dim index As Integer = End If
CInt([Link]([Link] - 1)) Next
TogglePassenger(pic, bowserInBoat, index) End Sub
End Sub
Private Sub PositionCharacterOnShore(pic As
' ==== PASSENGER HANDLING ==== PictureBox, index As Integer)
Private Sub TogglePassenger(pic As PictureBox, arr() As If boatLeft Then
Boolean, index As Integer) If [Link]().Contains("mario") Then
If Not arr(index) Then [Link] = LEFT_MARIO_START + ((index - 1) *
CHARACTER_SPACING)
If (boatM + boatC) >= MAX_BOAT_CAPACITY Then Else
[Link]("Boat is full!") [Link] = LEFT_BOWSER_START + ((index - 1) *
Return CHARACTER_SPACING)
End If End If
Else
arr(index) = True If [Link]().Contains("mario") Then
If [Link]().Contains("mario") Then [Link] = RIGHT_MARIO_START + ((index - 1) *
boatM += 1 CHARACTER_SPACING)
If boatLeft Then leftM -= 1 Else rightM -= 1 Else
Else [Link] = RIGHT_BOWSER_START + ((index - 1) *
boatC += 1 CHARACTER_SPACING)
If boatLeft Then leftC -= 1 Else rightC -= 1 End If
End If End If
Else [Link] = GROUND_Y - [Link]
End Sub
arr(index) = False ' ==== BOAT MOVEMENT ====
If [Link]().Contains("mario") Then Private Sub Boat_Click(sender As Object, e As
boatM -= 1 EventArgs) Handles [Link]
If boatLeft Then leftM += 1 Else rightM += 1 If boatM + boatC = 0 Then
Else [Link]("Boat cannot move empty!")
boatC -= 1 Return
If boatLeft Then leftC += 1 Else rightC += 1 End If
End If
PositionCharacterOnShore(pic, index) boatLeft = Not boatLeft
End If [Link] = If(boatLeft, boatPosLeft, boatPosRight)

RepositionBoatPassengers() RepositionBoatPassengers()
UpdateUI() UpdateUI()
CheckState() CheckState()
27 End Sub End Sub 24
Quizzes
' ==== UI + GAME RULES ====
Private Sub UpdateUI()
[Link] = $"Left: M={leftM}, C={leftC}"
[Link] = $"Right: M={rightM}, C={rightC}"
[Link] = $"Boat {(If(boatLeft, "Left", "Right"))}:
M={boatM}, C={boatC}"
End Sub

Private Sub CheckState()

If leftM > 0 AndAlso leftC > leftM Then


[Link]("Game Over! Left shore
cannibals ate missionaries!")
ResetGame()
ElseIf rightM > 0 AndAlso rightC > rightM Then
[Link]("Game Over! Right shore
cannibals ate missionaries!")
ResetGame()
ElseIf leftM = 3 AndAlso leftC = 3 AndAlso boatM = 0
AndAlso boatC = 0 Then
[Link]("You Win! Everyone made it to
the left shore!")
ResetGame()
End If
End Sub

' ==== RESET ====


Private Sub ResetGame()
leftM = 0 : leftC = 0
rightM = 3 : rightC = 3
boatM = 0 : boatC = 0
boatLeft = False
[Link] = boatPosRight
[Link] = BOAT_Y

For i = 1 To 3
marioInBoat(i) = False
bowserInBoat(i) = False
Next

InitialCharacterPositioning()
UpdateUI()
End Sub

End Class

25 26

You might also like