1 / 8

CS 241 – Computer Programming II Lab

CS 241 – Computer Programming II Lab . Kalpa Gunaratna – kalpa@knoesis.org http://knoesis.wright.edu/researchers/kalpa/. Contact . Contact by e-mail kalpa@knoesis.org Office hours 376 Joshi Mondays & Wednesday 3:00 pm – 4:00 pm. UML class diagram tips…. Basic class structure .

nura
Download Presentation

CS 241 – Computer Programming II Lab

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 241 – Computer Programming IILab KalpaGunaratna – kalpa@knoesis.org http://knoesis.wright.edu/researchers/kalpa/

  2. Contact • Contact by e-mail • kalpa@knoesis.org • Office hours • 376 Joshi • Mondays & Wednesday 3:00 pm – 4:00 pm

  3. UML class diagram tips…. • Basic class structure. • Access modifiers • + public, - private, # protected Class name <name> Variable declarations <access modifier>< <name> : <type> Method declarations <access modifier><name> (<name> : <type>) : <type>

  4. Java class and equivalent UML Class • Example : MyClass Public Class MyClass { Private int x; Public String y; Private void setVal(int z) { x = z; } Public String getName() { return y; } } - x : int + y : String + setVal(z : int) + getName() :String

  5. Comments • // - single line comment • /* */ - multiple line comments • /** */ - javadoc comments • Example JavaDoccommnet /** Takes input value y and calculates fixed amount and returns the calculated value. Pre-condition: value should be an integer of the range 1 – 9 Post-condition: value is equal to the expected amount @param y input integer value @return returns calculated value */ Public intcalcValue(int y) { return 5; }

  6. In lab • Draw UML class diagram and explain during the lab. • Put your method signature only into java class and should compile without any error. • All methods should have JavaDoc comment and inline comments or comment blocks. • UML and class should have all the methods listed in the assignment page.

  7. Post lab • Implement your stubbed java class. • Must have javadocs and comments as in in lab. • Call your methods and test whether they are working as mentioned in javadocs.

  8. enum • You can type enum with whatever name you want to use, lets say you need days of week to be represent in constants, enum Days{MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY}; • When you want to access MONDAY, use Days.MONDAY • See example in assignment. • More information and how to use enum: http://download.oracle.com/javase/tutorial/java/javaOO/enum.html

More Related