1
Student Name: __________________
Class and Section __________________
Total Points (10 pts) __________________
Due: September 9, 2009 before the class
Project: The MyInteger Class
CSCI 1302 Advanced Programming Principles
Armstrong Atlantic State University
Problem Description:
Design a class named MyInteger. The class contains:
An int data field named value that stores the int
value represented by this object.
A constructor that creates a MyInteger object for the
specified int value.
A get method that returns the int value.
Methods isEven(), isOdd(), and isPrime() that return
true if the value is even, odd, or prime,
respectively.
Design:
Draw the UML class diagram here
2
MyInteger
Coding: (Copy and Paste Source Code here. Format your code using Courier 10pts)
public class Exercise10_03 {
public static void main(String[] args) {
}
3
Submit the following items:
1. Print this Word file and Submit to me before the class on the due day.
2. Compile, Run, and Submit to LiveLab (you must submit the program regardless
whether it complete or incomplete, correct or incorrect)
Solution Code:
public class Test {
public static void main(String[] args) {
MyInteger n1 = new MyInteger(5);
}
}
class MyInteger {
private int value;
public int getValue() {
return value;
}
5
}
public boolean isOdd() {
return isOdd(value);
}
public static int parseInt(char[] numbers) {
// numbers consists of digit characters.
// For example, if numbers is {‘1’, ‘2’, ‘5’}, the return value
// should be 125. Please note that
// numbers[0] is ‘1’
// numbers[1] is ‘2’
// numbers[2] is ‘5’