EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 1, Problem 4PE
a.
Explanation of Solution
Three real-life objects that are instances of class Song:
- The song “Believer” is the instance of class Song...
b.
Explanation of Solution
Three real-life objects that are instances of class CollegeCourse:
- The song “Engineering” is the instance of class CollegeCourse...
c.
Explanation of Solution
Three real-life objects that are instances of class Musician:
- The song “HansZimmer” is the instance of class Musician...
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Question 6
Create a set of classes and interface for the following scenario:
Define an interface called Classical Music, which contains a get Year method that
returns the year the classical album released.
Create an abstract class Called CD. This class contains the title as String, and
playingTime as integer (e.g. 60 minutes). Include a constructor to initialize all the data
fields. Create an abstract method called printPlayingTime to show the CD playing
details. Make sure all the data fields can be accessed directly from the child classes.
Create a class called Album that inherits from the CD and Classical Music. Include
a data field called year as integer type. Create a constructor to initialize all the data
members. Override the getYear method to return the released year. Override the
printPlayingTime method. If the CD title is more than 10 characters, this method
will print the first 10 characters, followed by the three ellipse dots and the playing
time. For example:
Thriller 60…
5. class definition for GameEnemy
Next, we want to start making enemies for our upcoming video game, so we will define a class called GameEnemy.
Every GameEnemy will have a name, an x location, a y location, and a number of hit points (which must be a non-
negative integer ). The_init__ method for GameEnemy will take all of these parameters (in that order) and store them
on the object. GameEnemy also needs a method called healthbar, which will allow us to show that enemy's health bar in
the game. It returns the enemy's name followed by a number of asterisks to show how many hit points it has left. The
exact format is shown below.
Sample runs should look like:
>>> enemy = GameEnemy ("TODD", 100, 200, 5)
>>> enemy.healthbar()
TODD: ******
>>> enemy-%
ence
100
>>> enemy-y
200
If vou havo qu octiona
is a construct that defines objects of the same type.
A class
An object
A method
A data field
Chapter 1 Solutions
EBK JAVA PROGRAMMING
Ch. 1 - Prob. 1RQCh. 1 - Prob. 2RQCh. 1 - Prob. 3RQCh. 1 - Prob. 4RQCh. 1 - Prob. 5RQCh. 1 - Prob. 6RQCh. 1 - Prob. 7RQCh. 1 - Prob. 8RQCh. 1 - Prob. 9RQCh. 1 - Prob. 10RQ
Ch. 1 - Prob. 11RQCh. 1 - Prob. 12RQCh. 1 - Prob. 13RQCh. 1 - Prob. 14RQCh. 1 - Prob. 15RQCh. 1 - Prob. 16RQCh. 1 - Prob. 17RQCh. 1 - Prob. 18RQCh. 1 - Prob. 19RQCh. 1 - Prob. 20RQCh. 1 - Prob. 1PECh. 1 - Prob. 2PECh. 1 - Prob. 3PECh. 1 - Prob. 4PECh. 1 - Prob. 5PECh. 1 - Prob. 6PECh. 1 - Prob. 7PECh. 1 - Prob. 8PECh. 1 - Prob. 9PECh. 1 - Prob. 10PECh. 1 - Prob. 11PECh. 1 - Prob. 12PECh. 1 - Prob. 1DECh. 1 - Prob. 1GZCh. 1 - Prob. 1CPCh. 1 - Prob. 2CP
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a shoe class with the following attributes: color (e.g., "blue", "green", "orange") displayName (e.g., "nikes, adidas", "puma") price (e.g., 100, 200,60) Include only one constructor. It should have parameters for each of the attributes and set their values. Additionally, include getters and setters for each of the attributes. Add a driver, name it Purchases, and create 2 objects. Finally, print out some information about both objects (i.e., print the information from some or all of the getters). For example, if you created a shoe object whose color was blue, whose display name was shoes , for a price of 230, you could use the getters to print something like this:These work trousers are blue and cost $230arrow_forwardCreate an abstract class called vehicle. The class should declare the following variables: an instance variable that describes the model - String an instance variable that describes the number - String an instance variable that describes the maker - String an instance variable that describes the price - double an instance variable that describes the year – integer Provide a toString() method that returns the information stored in the above variables. Create the getter and setter methods for each instance variable except price. Provide the necessary constructors. Include an abstract method setPrice(double price) to determine the price for a vehicle. Include an abstract method getColor() to return the color of the vehicle. Create two subclasses called Car and Truck . These subclasses should override the abstract methods setPrice and getColor of class vehicle. Use the following rule for setting the price for a vehicle: car will have a 30% discount per each vehicle truck…arrow_forwardThis is the question I am stuck on - Create a class named Rock that acts as a superclass for rock samples collected and catalogued by a natural history museum. The Rock class contains the following fields: sampleNumber - of type int description - A description of the type of rock (of type String) weight - The weight of the rock in grams (of type double) Include a constructor that accepts parameters for the sample number and weight. The Rock constructor sets the description value to "Unclassified". Include get methods for each field. Create three child classes named IgneousRock, SedimentaryRock, and MetamorphicRock. The constructors for these classes require parameters for the sample number and weight. Search the Internet for a brief description of each rock type and assign it to the description field using a method named setDescription inside of the constructor. This is what I am given - import java.util.*; public class DemoRocks { public static void main(String[] args) {…arrow_forward
- Rectangle Object Monitoring Create a Rectangle class that can compute the total area of all the created rectangle objects using static fields (variables). Remember that a Rectangle has two attributes: Length and Width. Implement the class by creating a computer program that will ask the user about three rectangle dimensions. The program should be able to display the total area of the three rectangle objects. For this exercise, you are required to apply all OOP concepts that you learned in class. Sample output: Enter Length R1: 1 Enter Width R1: 1 Enter Length R2: 2 Enter Width R2: 2 Enter Length R3: 3 Enter Width R3: 3 The total area of the rectangles is 14.00 Note: All characters in boldface are user inputs.arrow_forwardCreates a class Student with 3 attributes: name, id and level. a. Add a constructor able to create a Student; b. Add the methods getId and getName; c. Add the method display able to display the attributes,arrow_forwardThe Point2D should store an x and y coordinate pair, and will be used to build a new class via class composition. A Point2D has a x and a y, while a LineSegment has a start point and an end point (both of which are represented as Point2Ds). class Invariants The start and end points of a line segment should never be null Initialize these to the origin instead. Data A LineSegment has a start point This is a Point2D object All data will be private A LineSegment also has an end point. Also a Point2D object Methods Create getters and setters for your start and end points public Point2D getStartPoint() { public void setStartPoint(Point2D start) { Create a toString() function to build a string composed of the startPoint’s toString() and endPoint’s toString() Should look like “Line start(0,0) and end(1,1)” Create an equals method that determines if two LineSegments are equal public boolean equals(Object other) { if(other == null || !(other instanceof LineSegment)) return…arrow_forward
- subject: object-oriented programming in your library there are two types of books. one category is literature books and the second category is generals. litrature books have the authorID, authorname literature theme language, publisher, volumn,, yearofpubication, journal have attributes volumn, issue, publisher,yearofpublication,journalID, technical sponser. design a parent class books extend two classes literaturebooks and journel from parent class make constructor , setter, and getterarrow_forwardCreate a class of Dog, some of the differences you might have listed out maybe breed, age, size, color, etc. Then create characteristics (breed, age, size, color) can form a data member for your object. Then list out the common behaviors of these dogs like sleep, sit, eat, etc. Design the class dogs with objects and methods.arrow_forwardClass: Square Create a class called "Square", which is inherited from“TwoDimensionShape” class. The "Square" class is used to calculate theArea and the Perimeter of square shapes when their side-length is given, or in contrast,finding the side-length of the square when the Area or the Perimeter of the square is given.The specifications of this class are below. Data Members (Attributes): All are private. sideLength: the sidelight (L) of the square. Methods/Operations/Getters/Setters: Default Constructor: when creating an object this constructor must set the side-length of the square by calling the method setSideLength(). Also, this constructor willcall the findArea() and the findPerimeter() in addition to summaryPrint() to calculateand print all needed information. User-Defined Constructor: when creating an object this constructor shouldfind the side-length of the square by calling the method findSquareSideLength()and pass the Area or the…arrow_forward
- 1 - Student class Make a class student (in student.py) that stores the following information for a student: Name (name) Student number (student_nr) Points per assignment (points_per_assignment) Exam grade (exam_grade) a) Behind each point of information is the name of the parameter to the initializer method. Store this information from the parameters in the object attributes with the same name. b) Add a method course_points() which returns the number of course points the student has gotten. Example: mary = Student("Mary", 15789613, [10, 9, 8, 10, 9, 10], 9)print(mary.course_points()) > 121 The calculation of the course points is explained in the course overview, course setup slides (Links to an external site.) and the first lectureLinks to an external site.. c) Add a method grade() which returns a the final grade of the student, rounded to nearest half (upwards, 6.75 -> 7). As per regulations, a 5.5 becomes a 6. If the student did not pass both the assignments (>= 95…arrow_forwardA TV Class The attributes of a TV object are the channel, the volume, and a flag (or switch) indicating whether the TV is on or off. The methods perform the following actions: • Turn the TV on or off. • Set the channel to an integer from 0 to 99 inclusive. • Raise or lower the volume by one unit. The volume can range from 0 to 20. • View the value of the volume. • View the channel. • Determine whether the TV is on or off. Write a TV class that implements all relevant functions. A newly created TV object is set to off with the channel set to 2 and the volume initially 10. Include a main(...) method that tests the methods of the TV class.arrow_forwardCreate an abstract class called Movie. The class should declare the following variables: an instance variable that describes the title - String an instance variable that describes the rating - double an instance variable that describes the director - String an instance variable that describes the genre - String an instance variable that describes the year – integer an instance variable that describes the language – String an instance variable that describes the ticket price - double Create the getter and setter methods for each instance variable except setter for ticket price and getter for genre. Create the necessary constructors. Include an abstract method setTicketPrice(double ticketPrice) to determine the ticket price for a movie. Include an abstract method getGenre() to return the genre of the movie. Provide a toString() method that returns the information stored in the above variables. Create three subclasses called ThrillerMovie, ComedyMovie, and ChildrenMovie. These…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Memory Management Tutorial in Java | Java Stack vs Heap | Java Training | Edureka; Author: edureka!;https://www.youtube.com/watch?v=fM8yj93X80s;License: Standard YouTube License, CC-BY