Академический Документы
Профессиональный Документы
Культура Документы
Chapter 7
Exercise 7.2:
Fan
+SLOW = 1 Constant.
+MEDIUM = 2 Constant.
+FAST = 3 Constant.
-speed: int The speed of this fan (default 1).
-on: boolean Indicates whether the fan is on (default false).
-radius: double The radius of this fan (default 5).
-color: String The color of this fan (default white).
1
Exercise 7.4:
Stock
+Stock(symbol: String, name: String) Constructs a stock with a specified symbol and a name.
+getSymbol():String Returns the symbol of this stock.
+getName():String Returns the name of this stock.
+getPreviousClosingPrice(): double Returns the previous closing price of this stock.
+getCurrentPrice(): double Returns the current price of this stock.
+setPreviousClosingPrice(price: double): void Sets the previous closing price of this stock.
+setCurrentPrice(price: double): void Sets the current price of this stock.
+getChangePercent(): double Returns the percentage of change of this stock.
2
Exercise 9.4:
MyPoint
-x: double x-coordinate of this point.
-y: double y-coordinate of this point.
+MyPoint() Constructs a Point object at (0, 0).
+MyPoint(x: double, y: double) Constructs an object with specified x and y values.
+getX(): double Returns x value in this object.
+getY(): double Returns y value in this object.
+distance(secondPoint: MyPoint): double Returns the distance from this point to another point.
+distance(p1: Point, p2: MyPoint): double Returns the distance between two points.
Exercise 9.8:
Tax
-filingStatus: int
-brackets: int[][]
-rates: double[]
-taxableIncome: double
+Tax()
+Tax(filingStatus: int, brackets: int[], rates: double[],
taxableIncome: double)
+getFilingStatus(): int
+setFilingStatus(filingStatus: int): void
+getBrackets(): int[][]
+setBrackets(brackets: int[][]): void
+getRates(): double[]
+setRates(rates: double[]): void
+getTaxableIncom(): double
+setTaxableIncome(taxableIncome: double): void
+getTax(): double
3
Chapter 10
Exercise 10.2:
Person
Student Employee
Faculty Staff
Person Student
-name: String -status: String
-address: String +Student()
-phone: String
+Student(name: String, address:
-email: String String, phone: String, email:
+Person() String)
Employee Faculty
-office: String -officeHour: String
-salary: int -rank: String
-dateHired: java.util.Date +Faculty()
+Employee() +Faculty(name: String, address: String,
phone: String, email: String)
+Employee(name: String, address:
String, phone: String, email: String) +getOfficeHour(): String
+getOffice(): String +setOfficeHour(officeHour: String): void
+getSalary(): int +getRank(): String
+getDateHired(): Date +setRank(rank: String): void
+setOffice(office: String): void +toString(): String
+setSalary(salary: int): void
+setDateHired(dataHired: Date): void
+toString(): String
4
Staff MyDate
-title: String -year: int
+Staff() -month: int
-day: int
+Staff(name: String, address: String,
phone: String, email: String) +Faculty()
5
Exercise 10.4:
Account
MyStack SavingsAccount
MyArrayList
MyStack
+isEmpty(): boolean Returns true if this stack is empty.
+getSize(): int Returns the number of elements in this stack.
+peek(): Object Returns the top element in this stack.
+pop(): Object Returns and removes the top element in this stack.
+push(o: Object): Object Adds a new element to the top of this stack.
+search(o: Object): int Returns the position of the first element in the stack from
the top that matches the specified element.
6
Chapter 11
Exercise 11.2:
«interface» Circle
java.lang.Comparable
ComparableCircle
+ComparableCircle(radius: double)
+compareTo(): int
7
Exercise 11.6:
«interface»
Comparable
+compareTo(): int
GeometricObject
Rectangle
8
Chapter 12
Exercise 12.2:
Comparable