Git Product home page Git Product logo

cpit305-fall-2023's Introduction

CPIT 305 Advanced Programming

This repository contains all code done during lectures.

Topics

  1. Review
  2. IO Stream
  3. Exception Handling
  4. Threads

Review

IO Stream

Here the class diagram for all IO Stream IO Stream Class diagram

  • User Input using System.in and Scanner
  • Text File
    • Write text file using
    • Read text file using FileInputStream and array of byte
    • Read text file using BufferedReader and InputStreamReader Lecture 04
  • Binary File with fixed string an example of data recored (int, char[15], double)
    • Write binary file
    • Read binary file using DataInputStream
      • read single recored from file by moving file currsor into specifc position in the file Lecture 04
      • read whole file recored by recored until reaching end of file using EOFException Lecture 04
  • Using input mark and reset from BufferedInputStream Lecture 05
  • Read/Write binary file using RandomAccessFile Lecture 05
  • Binary file simulate database management system that include (add/edit/delete/search) using RandomAccessFile Lecture 06
  • File usage:
    • Reterive file information and check its existance Lecture 07
    • Create new file and delete it Lecture 07
    • Create new Directory and delete it using Lecture 07
    • Using JFileChooser and list selected directory files Lecture 07
    • List all files and directories and sub-directories recursively as a tree Lecture 07
  • Working with class instance to be stored/read in/from a file using ObjectOutputStrea and ObjectInputStream Lecture 09
    • First you make sure your class is serializable (implements Serializable)
    • Write Object onto file Lecture 09
    • Read Several stored objects from a binary file Lecture 09

Exception Handling

Threads

Thread States

  • Example of calculating the sum of an array using:
  • Example of shared resource between threads:
    • Counter: Two threads increasing static variable shared between them. Each thread increases the counter 1000000 times, so the final value of counter after both threads should be 2000000
      • incorrect way to increase a counter using several threads Lecture 09
      • solve for previous example
    • Bank and ATM: A bank has several customers' accounts. ATMs use an instance of that bank and call transfer method in order to transfere from account to another. Each ATM works as a thread. The transfer occors in the same time which may cause unexpected result. That is, bank instance initilized with number of accounts with initial amount of 1000.0 SAR. Assume that number of accounts is 10. The total balance of the bank should always 1000.0 * 10 = 10000.0; however, do to the concurrent transfer the total bank balance change which it should not.
      • Unsolved example: Lecture 10
      • Solved example:
        • using synchronized keyword with transfer method signture Lecture 10
        • using synchronized block Lecture 10

Folder Structure

The workspace contains two folders by default, where:

  • src: the folder to maintain sources
  • lib: the folder to maintain dependencies

Meanwhile, the compiled output files will be generated in the bin folder by default.

If you want to customize the folder structure, open .vscode/settings.json and update the related settings there.

Dependency Management

The JAVA PROJECTS view allows you to manage your dependencies. More details can be found here.

cpit305-fall-2023's People

Contributors

marwankau avatar mtuts avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.