In Listing 5.12, we set the data for the object speciesOfTheMonth as follows:
speciesOfTheMonth.setSpecies(“Klingon ox”, 10, 15);
Could we have used the following code instead?
speciesOfTheMonth.name = “Klingon ox”;
speciesOfTheMonth.population = 10;
speciesOfTheMonth.growthRate = 15;
If we could have used this alternative code, why didn't we? If we could not have used this alternative code, explain why we could not use it.
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
Concepts Of Programming Languages
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
Modern Database Management
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- ---for example, Data abstraction is a powerful concept in computer science that allows programmers to treat code as objects car objects, chair objects, people objects, etc. That way, programmers don't have to worry about how code is implemented they just have to know what it does. Data abstraction mimics how we think about the world. For example, when you want to drive a car, you don't need to know how the engine was built or what kind of material the tires are made of. You just have to know how to turn the wheel and press the gas pedal. An abstract data type consists of two types of functions: • Constructors: functions that build the abstract data type. • Selectors: functions that retrieve information from the data type. For example, say we have an abstract data type called city. This city object will hold the city's name, and its latitude and longitude. To create a city object, you'd use a constructor like city=make_city (name, lat, lon) To extract the information of a city object,…arrow_forwardWrite in python and please include docstring. Write a class named Employee that has private data members for an employee's name, ID_number, salary, and email_address. It should have an init method that takes four values and uses them to initialize the data members. It should have get methods named get_name, get_ID_number, get_salary, and get_email_address. Write a separate function (not part of the Employee class) named make_employee_dict that takes as parameters a list of names, a list of ID numbers, a list of salaries and a list of email addresses (which are all the same length). The function should take the first value of each list and use them to create an Employee object. It should do the same with the second value of each list, etc. to the end of the lists. As it creates these objects, it should add them to a dictionary, where the key is the ID number and the value for that key is the whole Employee object. The function should return the resulting dictionary. For example, it…arrow_forwardI need help writing a program for this on pythonarrow_forward
- Create a class Employee with following data members, name, id, and salary as private data member. Create array of objects for four employees, compare their salary using operator overloading, and display the records of the student who is getting less salary.arrow_forwardWrite a java program that uses a structure to store the information about the Items in a retail store. It has Items with name, manufacturer (Final) and price. Provide default & Parameterized constructors. Provide getters & setters for data members. Provide A toString() method to print values. We can add several items to Store. Now create another class store which has name, city and array of Items. Provide default & Parameterized constructors. Provide getters & setters for data members. Provide necessary validation checks ( null pointer exception, index out of bounds,etc). where possible. Provide a method AddItem (Item i) which is used to add items into the store, but number of items should be less than the size of array (check for exception). A print function which shows all items in the store. Create Test Application and test the functionality of above classes.arrow_forwardYour task is to create a class name polygon that contains 2 data members i.e. length of type float and width (a pointer of type float). Create a single object named “one” in the main and assign values to the data member of the polygon object. Then create another object named “two” that is a copy of the “one”. Create a shallow copy constructor that copies only the pointer data member of the class polygon and then demonstrate that both objects share a common memory i.e. modifying one object in fact modifies the other.Create a display function that will show the values of the polygon object.arrow_forward
- advanced java For this assignment you will write a program to represent geometric shapes and some operations that can be performed on them. The idea here is that shapes in higher dimensions inherit data from lower dimensional shapes. For example a cube is a three dimensional square. A sphere is a three dimensional circle and a glome is a four dimensional circle. A cylinder is another kind of three dimensional circle. The circle, sphere, cylinder, and glome all share the attribute radius. The square and cube share the attribute side length. There are various ways to use inheritance to relate these shapes but please follow the inheritance described in the table below. All shapes inherit getName() from the superclass Shape. Specification: The program should have the following classes: Shape, Circle, Square, Cube, Sphere, Cylinder, and Glome and two interfaces Area and Volume (Area.java and Volume.java are given below). The volume of a glome is 0.5(π2)r4 where r is the radius. Your classes…arrow_forwardCreate a class Student with following data members- name, roll no and marks as private data member. Create array of objects for three students, compare their marks using operator overloading, and display the records of the student who is getting highest score.arrow_forwardPart 2: Sorting the WorkOrders via dates Another error that will still be showing is that there is not Comparable/compareTo() method setup on the WorkOrder class file. That is something you need to fix and code. Implement the use of the Comparable interface and add the compareTo() method to the WorkOrder class. The compareTo() method will take a little work here. We are going to compare via the date of the work order. The dates of the WorkOrder are saved in a MM-DD-YYYY format. There is a dash '-' in between each part of the date. You will need to split both the current object's date and the date sent through the compareTo() parameters. You will have three things to compare against. You first need to check the year. If the years are the same value then you need to go another step to check the months, otherwise you compare them with less than or greater than and return the corresponding value. If you have to check the months it would be the same for years. If the months are the same you…arrow_forward
- Written in Python with docstring please if applicable Thank youarrow_forwardIn GO language. Create a struct that has student name, id, and GPA. Write functions to create a student, modify the student’s id, and modify the student's GPA, and print the student’s information. (This is like creating a class and methods). Now create an array of three students and test your functions. You may hardcode your values if using a web conpiler. (Please hardcode the values!)arrow_forwardWrite a base class (Person) that has the following data members: String name, long NID, int age. Your class (Person) should have setters and getters for all data members. Derive a class (Student) from class (Person). Class student should have the following private data members: Int id, double GPA, string major. Class (Student) should have setters and getters for its private data members. In your main function, create an object of class (Student) and set all of its data members.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education