Download presentation
Presentation is loading. Please wait.
Published byEvelyn Barnard Douglas Modified over 9 years ago
1
CS 241 – Computer Programming II Lab Kalpa Gunaratna – kalpa@knoesis.orgkalpa@knoesis.org http://knoesis.wright.edu/researchers/kalpa/
2
Contact Contact by e-mail kalpa@knoesis.org 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 Variable declarations : Method declarations ( : ) :
4
Java class and equivalent UML Class Example : Public Class MyClass { Private int x; Public String y; Private void setVal(int z) { x = z; } Public String getName() { return y; } MyClass - x : int + y : String + setVal(z : int) + getName() :String
5
Comments // - single line comment /* */ - multiple line comments /** */ - javadoc comments Example JavaDoc commnet /** 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 int calcValue(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.h tml http://download.oracle.com/javase/tutorial/java/javaOO/enum.h tml
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.