Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC305 Lecture 09

CSC305 Lecture 09

Individual Software Design and Development
Assignment
(202410)

Javier Gonzalez-Sanchez

October 10, 2024
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227

    CSC 305 Individual Software Design and Development Lecture 09. Assignment
  2. Clean Code Re a d a bility • DRY •

    KIS • SRP • Comments • Error H a ndling with a Logger 4 Metrics • LOC (eLOC, lLOC) • CC • A • I • D
  3. Tower of Hanoi Move a st a ck of disks

    from one rod to a nother, following three simple rules: 1. Only one disk c a n be moved a t a time, 2. A l a rger disk c a nnot be pl a ced on top of a sm a ller one. 7
  4. Code class GFG { void towerOfHanoi(int n, char from_rod, char

    to_rod, char aux_rod) { if (n == 0) return; towerOfHanoi(n - 1, from_rod, aux_rod, to_rod); System.out.println("Move disk " + n + " from rod “ + from_rod + " to rod “ + to_rod); towerOfHanoi(n - 1, aux_rod, to_rod, from_rod); } public static void main(String args[]) { int N = 3; // A, B, and C are the names of the rods towerOfHanoi(N, 'A', 'C', 'B'); } } 10
  5. Step 2 14 Show the board 111 or ABC ___

    ___ or | | | A | | B | | C | | ——— ——— ———
  6. Step 5 18 Users can ask for HELP And the

    computer should move, It should make a good move!
  7. Question 19 How many classes? Class Diagram! A I How

    many methods? CC LOC Develop It!
  8. CSC 305 Individual Software Design and Development Javier Gonzalez-Sanchez, Ph.D.

    [email protected] Summer 2024 Copyright. These slides can only be used as study material for the class CSC305 at Cal Poly. They cannot be distributed or used for another purpose.