Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
Question
Create functional tests where arguments are given, use a parameterized test.
- testSimpleInit(size): the first constructor works as expected.
- getTiles shows suitable values.
- The edges of the board (the smallest and biggest conceivable values) are accessible and contain the values that they have to (BASE_TILE_SCORE).
- testCustomInit(x, y, expected): the second constructor works as expected.
- On positions where values smaller than three were passed, the board contains the value BASE_TILE_SCORE.
- If you pass an array to the constructor and later modify a value in it, the respective tile retains the originally passed value.
- If you modify an element in the return value of getTiles(), and get the value of the respective tile again, this newly received content has to be the originally set value.
- testMoves(): take four or five steps and check that the board’s contents are changed just right.
- Include a step that tries to move to the x coordinate Integer.MIN_VALUE and another one that moves to the y coordinate 666.
- Include a step that tries to move outside of the board. In this case, check that both the position and the board’s contents are unchanged.
privateint[][] tiles; //getter method bhgu
privateintx;
privateinty;
publicstaticfinalintBASE_TILE_SCORE=3;
publicWalkingBoard(intsize) {
this.tiles=newint[size][size];
for (inti=0; i < size; i++) {
for (intj=0; j < size; j++) {
this.tiles[i][j] = BASE_TILE_SCORE;}
}
this.x=0;
this.y=0;
}
publicWalkingBoard(int[][] tiles) {
this.x=0;
this.y=0;
int[][] copy=newint[tiles.length][];
for (inti=0; i <tiles.length; i++) {
introwLength= tiles[i].length;
copy[i] = new int[rowLength];
for (intj=0; j < rowLength; j++) {
copy[i][j] = Math.max(this.BASE_TILE_SCORE, tiles[i][j]);
}
}
this.tiles= copy;
}
publicint[] getPosition() {
returnnewint[]{x, y};
}
publicbooleanisValidPosition(intx, inty) {
return x >=0&& x <tiles.length&& y >=0&& y < tiles[0].length; //indexing - tiles 0;; tiles[0].length--> how to do it if uniform
}
publicintgetTile(intx, inty) {
if (isValidPosition(x, y)) {
return tiles[x][y];
}
elsethrownewIllegalArgumentException("Invalid Position");
}
publicint[][] getTiles(){
int[][] copy=newint[tiles.length][];
for (inti=0; i <tiles.length; i++) {
introwLength= tiles[i].length;
copy[i] = new int[rowLength];
for (intj=0; j < rowLength; j++) {
copy[i][j] = tiles[i][j];
}
}
return copy;
}
publicstaticintgetXStep(Directiondirection) {
switch (direction) {
case UP:
return1;
case DOWN:
return-1;
case RIGHT:
return0;
case LEFT:
return-0;
default:
thrownewIllegalArgumentException("Invalid direction");
}
}
publicstaticintgetYStep(Directiondirection) {
switch (direction) {
case UP:
return0;
case DOWN:
return0;
case RIGHT:
return1;
case LEFT:
return-1;
default:
thrownewIllegalArgumentException("Invalid direction");
}
}
publicintmoveAndSet(Directiondirection, intvalue) {
intnewX= x +getXStep(direction);
intnewY= y +getYStep(direction);
if (newX <0|| newX >=tiles.length|| newY <0|| newY >= tiles[newX].length) {
return0;
} else {
x = newX;
y = newY;
intoldValue= tiles[x][y];
tiles[x][y] = value;
return oldValue;
}
}
publicintsetAndMove(Directiondirection, intvalue) {
tiles[x][y] = value;
intnewX= x +getXStep(direction);
intnewY= y +getYStep(direction);
if (newX <0|| newX >=tiles.length|| newY <0|| newY >= tiles[newX].length) {
return0;
} else {
x = newX;
y = newY;
return tiles[x][y];
}
}
}
SAVE
AI-Generated Solution
info
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
bartleby
Unlock instant AI solutions
Tap the button
to generate a solution
to generate a solution
Click the button to generate
a solution
a solution
Knowledge Booster
Background pattern image
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
- Sally and Harry implement two different compareTo methods for a classthey are working on together. Sally’s compareTo method returns −1, 0, or +1,depending on the relationship between two objects. Harry’s compareTo methodreturns −6, 0, or +3. Which method is suitable?arrow_forwardmau Open Leathing inta... - The class has data members that can hold the name of your cube, length of one of the sides and the color of your cube. - The class has a constructor that accepts the name, length of one of the sides, and color as arguments and sets the data members to those values. - The class has the following methods to set the corresponding data member. setName(string newName) setSide(double newSide) setColor(string newColor) - The class has a method called getVolume() that returns the volume of the cube, calculated by cubing the length of the side. - The class has a method called volumelncrease(double newVolume) that receive the percent the volume should increase, and then the side to the corresponding value. i - For example, 2.5 indicates 2.5% increasing of the volume. So you take the current volume, increase it by 2.5%, and then find the cube root to calculate the new side length. You can use the built in function called cbrt, part of the math library, to find the cube...arrow_forwardAn object of the class Timer is used to indicate when a certain amount of time (in seconds) has elapsed, after which it provides a "DING". The required data field is remainingTime which is the number of seconds until the "DING". When a Timer object is constructed, it is set with the desired number of seconds. When the timer "ticks", it is one second closer to the "DING". This is represented with the tick) method. The dingChecko method indicates whether the timer should be "DINGING". Provide the code for the constructor method, and the methods getRemainingTime), tick(), and dingCheck). public class Timer // Methods // Data private int KeuainingTinei }arrow_forward
- Add three methods to the Student class that compare twoStudent objects. One method (__eq__) should test for equality. A second method (__lt__) should test for less than. The third method (__ge__) should test for greater than or equal to. In each case, the method returns the result of the comparison of the two students’ names. Include a main function that tests all of the comparison operators. Note: The program should output in the following format: False: False True: True True: True False: False True: True True: True True: True True: True True: True True: True ks Add method to test for equality Add method to test for less than Add method to test for greater than or equal toarrow_forward15arrow_forwardThe goal of this coding exercise is to create two classes BookstoreBook and LibraryBook. Both classes have these attributes: author: Stringtiltle: Stringisbn : String- The BookstoreBook has an additional data member to store the price of the book, and whether the book is on sale or not. If a bookstore book is on sale, we need to add the reduction percentage (like 20% off...etc). For a LibraryBook, we add the call number (that tells you where the book is in the library) as a string. The call number is automatically generated by the following procedure:The call number is a string with the format xx.yyy.c, where xx is the floor number that is randomly assigned (our library has 99 floors), yyy are the first three letters of the author’s name (we assume that all names are at least three letters long), and c is the last character of the isbn.- In each of the classes, add the setters, the getters, at least three constructors (of your choosing) and override the toString method (see samplerun...arrow_forward
- Create a Class Student in which we have three instance variables emp_name, emp_id, and Salary. Write getter and setters for each instance variable. Write another Display method that displays the record of Employee. In Main create five Employee’s Objects. Set their values as required and display as well. In the end Display top three employees with respect to Salary (Display those who have more Salary among all).arrow_forwardComplete the Car class by creating an attribute purchase_price (type int) and the method print_info() that outputs the car's information. Ex: If the input is: 2011 18000 2018 where 2011 is the car's model year, 18000 is the purchase price, and 2018 is the current year, then print_info() outputs: Car's information: Model year: 2011 Purchase price: 18000ドル Current value: 5770ドル Note: print_info() should use two spaces for indentation.arrow_forwardPlease help with this, I am kinda lost. bagDifference: The difference of two bags is a new bag containing the entries that would be left in one bag after removing those that also occur in the second. Design and specify a method difference for the ArrayBag that returns as a new bag the difference of the bag receiving the call to the method and the bag that is the method's parameter. The method signature is: ArrayBag<ItemType> bagDifference(const ArrayBag<ItemType> &otherBag) const; Note that the difference of two bags might contain duplicate items. For example, if object x occurs five times in one bag and twice in another, the difference of these bags contains x three times. Here is the all of the file: ArrayBag.cpp: #include <string>#include "ArrayBag.h" template <class T>ArrayBag<T>::ArrayBag() : itemCount(0) {// itemCount = 0;} template <class T>ArrayBag<T>::ArrayBag(const ArrayBag& orig) {itemCount = orig.itemCount;for (int i...arrow_forward
- Using an appropriate package and test class name, write the following tests for GamerProfile's constructor: testNameShouldNotBeNull testNameShouldNotBeEmpty testNameShouldNotBeBlank testShouldCreateValidGamerProfile Hint: use assertTrue or assertFalse for getters involving boolean values Hint: get the game list from the gamer and call the list's isEmpty along with an assertTrue or assertFalse, as appropriate.GamerProfile:public class GamerProfile { private String userName; private boolean pvpEnabled; private boolean online; private ArrayList<GameInfo> gameLibrary; public GamerProfile(String userName) { this.userName = userName; this.pvpEnabled = false; this.online = false; gameLibrary = new ArrayList<GameInfo>(); } // Getter for the getUserName variable public String getUserName() { return userName; } // Getter for the PvpEnabled...arrow_forwardjava please dont take other website'answer. rthis is actually practice question ANIMALCLASS Create an Animal class. Each animal has a name, an x and y integer coordinate. The Animal class should have at minimum the following methodsbelowbut you may want to add more if necessary: Also note, everyanimal will need to have to have "z"passed to it so that it knows how big the map is. •A constructor that starts the animal at 0,0 with a name of "Unknown Animal"and only accepts a single int value (int mapSize). •A parameter constructor that allows the programmerto input all 4pieces of information.(x,y, name, mapSize)oCheck the parameters for valid input based on the constraints. Ifany of the input valuesis invalid, adjust it any way you deem necessary in order to make it valid. •getX()and getY() •getName() •toString(). o This should print out the name and coordinates of the animal. •touching(Animal x) This method should determine if the animal is on the same spot as a secondanimal(x). It...arrow_forwardHelp, I am making a elevator simulation using polymorphism. I am not sure to do now. Any help would be appreciated. My code is at the bottom, that's all I could think off. There are 4 types of passengers in the system:Standard: This is the most common type of passenger and has a request percentage of 70%. Standard passengers have no special requirements.VIP: This type of passenger has a request percentage of 10%. VIP passengers are given priority and are more likely to be picked up by express elevators.Freight: This type of passenger has a request percentage of 15%. Freight passengers have large items that need to be transported and are more likely to be picked up by freight elevators.Glass: This type of passenger has a request percentage of 5%. Glass passengers have fragile items that need to be transported and are more likely to be picked up by glass elevators. public abstract class Passenger { public static int passangerCounter = 0; private String passengerID; protected...arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education