Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 4 out of 185 pages
Exam (elaborations)

Solution Manual for Comprehensive Introduction to Object Oriented Programming with Java 1st Edition Thomas Wu, (Chapter 1 - 15 ) Latest Guide

Document preview thumbnail
Preview 4 out of 185 pages

Solution Manual for Comprehensive Introduction to Object Oriented Programming with Java 1st Edition Thomas Wu, (Chapter 1 - 15 ) Latest Guide

Content preview

Solution Manual

Comprehensive Introduction To Object Oriented
Programming With Java
By Thomas Wu,


1st Edition

, Chapter 1 Solutions

1.1 Graphically Represent A Vehicle Class And Three Vehicle Objects Named Car1,
Car2, And Car3.


Vehicle




car1:Vehicle car2:Vehicle car3:Vehicle




1.2 Graphically Represent A Person Class With The Following Components:
• Instance Variables Name, Age, And Gender.
• Instance Methods Setname, Getname, And Getage.
• Class Method Getaverageage.

Person
Setname()
Name
Getage()
Age Age

Getgender() Gender
Gender

Getaverageage()
Average Age


1.3 Design A CD Class Where A CD Object Represents A Single Music CD. What
Kinds Of Information (Artist, Genre, Total Playing Time, Etc.) Do You Want To
Know About A CD? Among The Information In Which You Are Interested,
Which Are Instance Variables? Are There Any Class Variables Or Class
Constants?

State
Album Name Instance Variable
Artist Instance Variable
Genre Instance Variable
Total Playing Time Instance Variable
Maximum Playing Time Class Constant

, Behaviors
Getalbumname(), Setalbumname() Instance Methods
Getartist(), Setartist() Instance
Methods
Getgenre(), Setgenre() Instance
Methods Getplayingtime(), Setplayingtime() Instance
Methods Getmaxplayingtime() Class Method

Students May Also Include A List Of Songs On The CD And Methods To Access
Them. A Song Itself Would Probably Have Its Own Class To Represent It.
However This Concept Is More Advanced Than Is Necessary At This Stage.

1.4 Suppose The Vehicle Class In Exercise 1 Is Used In A Program That Keeps
Track Of Vehicle Registration For The Department Of Motor Vehicles. What
Kinds Of Instance Variables Would You Define For Such Vehicle Objects?
Can You Think Of Any Useful Class Variables For The Vehicle Class?

Instance Variables
Owner
Licenseid
Registrationnumber
Make
Mode
l
Color
Value

Class Variables
At This Stage, The Number Of Total Vehicles Could Be Thought To
Belong To The Class. Information Relating To The Length Of A
Licenseid Or Registrationnumber Could Be Stored As Class Constants.
Aside From These, There Are No Obviously Necessary Traits For Which
All Vehicles Share The Same Value Or Which The Class May Need To
Function.

1.5 Suppose The Following Formulas Are Used To Compute The Annual
Vehicle Registration Fee For The Vehicle Registration Program In
Exercise 1.4:
• For Cars, The Annual Fee Is 2 Percent Of The Value Of The Car.
• For Trucks, The Annual Fee Is 5 Percent Of The Loading
Capacity (In Pounds) Of The Truck.
Define Two New Classes Car And Truck As Subclasses Of Vehicle.
Hint: Associate Class And Instance Variables Common To Both Car And Truck
To Vehicle.

Vehicle Class
See Exercise 1.4

Car Class (Subclass Of Vehicle)
Registrationrate Class Constant

, Note: Value Is Already An Instance Variable In Vehicle Since All
Vehicles Have Some Value.

Truck Class (Subclass Of Vehicle)
Registrationrate Class Constant
Loadingcapacity Instance Variable

1.6 Consider A Student Registration Program Used By The Registrar’s Office. The
Program Keeps Track Of Students Who Are Registered For A Given Semester.
For Each Student Registered, The Program Maintains The Student’s Name,
Address, And Phone Number; The Number Of Classes In Which The Student Is
Enrolled And The Student’s Total Credit Hours. The Program Also Keeps Track
Of The Total Number Of Registered Students. Define Instance And Class
Variables Of A Student Class That Is Suitable For This Program.

Instance Variables
Name
Address
Phonenumber
Numclassesthissemester
Totalcredithours

Class Variables
Numstudentsregistered

1.7 Suppose The Minimum And Maximum Number Of Courses For Which A
Student Can Register Are Different Depending On Whether The Student Is A
Graduate, Undergraduate, Or Work-Study Student. Redo Exercise 6 By
Defining Classes For Different Types Of Students. Relate The Classes Using
Inheritance.

Student
See Exercise 1.6

Graduatestudent (Subclass Of Student)
Maximumhours Class Constant
Minimumhours Class Constant

Undergraduatestudent (Subclass Of Student)
Maximumhours Class
Constant
Minimumhours Class Constant

Workstudystudent (Subclass Of Student)
Maximumhours Class Constant
Minimumhours Class Constant

Connected book
 image
Publisher: 2007 ISBN: 9780073317083 Edition: Unknown

Document information

Uploaded on
April 12, 2025
Number of pages
185
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$15.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Examarena
3.2
(31)
Sold
394
Followers
33
Items
480
Last sold
4 days ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions