lab 5
.docx
keyboard_arrow_up
School
Arizona State University *
*We aren’t endorsed by this school
Course
360
Subject
Computer Science
Date
Dec 6, 2023
Type
docx
Pages
9
Uploaded by ProfStraw17234
Jordan Whitecar
IFT360 Lab 5
Class explanations:
EightQueenGame: this class defines the game being run, it sets the rules for how the pieces can move,
and how the game is run.
EightQueenGameSolver: this class is the AI that attempts to solve the game, it contains several different
“methods” of doing this, including two different brute force methods, a hill-climbing method, and when
complete, a simulated annealing method.
1)
2)
3)
Hill climbing method starts with a solution:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
fix and remove errors
arrow_forward
java programming language
You are part of a team writing classes for the different game objects in a video game. You need to write classes for the two human objects warrior and politician. A warrior has the attributes name (of type String) and speed (of type int). Speed is a measure of how fast the warrior can run and fight. A politician has the attributes name (of type String) and diplomacy (of type int). Diplomacy is the ability to outwit an adversary without using force.
From this description identify a superclass as well as two subclasses. Each of these three classes need to have a default constructor, a constructor with parameters for all the instance variables in that class (as well as any instance variables inherited from a superclass) accessor (get) and mutator (set) methods for all instance variables and a toString method. The toString method needs to return a string representation of the object. Also write a main method for each class in which that class is tested – create…
arrow_forward
fix code and remove errors
arrow_forward
Library Information System Design and Testing
Library Item Class Design and TestingDesign a class that holds the Library Item Information, with item name, author, publisher. Write appropriate accessor and mutator methods. Also, write a tester program(Console and GUI Program) that creates three instances/objects of the Library Items class.
Extending Library Item Class Library and Book Classes: Extend the Library Item class in (1) with a Book class with data attributes for a book’s title, author, publisher and an additional attributes as number of pages, and a Boolean data attribute indicating whether there is both hard copy as well as eBook version of the book. Demonstrate Book Class in a Tester Program (Console and GUI Program) with an object of Book class.
arrow_forward
Using Visual Studio
C# Language
Note: not a User Input
arrow_forward
solve with java
Create a class for Subject containing the Name of the subject and score of the subject. There should be following methods:
set: it will take two arguments name and score, and set the values of the attributes. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero.
set: it will take one double value as argument and set the value of score only. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero.
display: it will display the name and score of the subject. Like “Name : Math, Score: 99.9”
getScore: it will return the value of score.
greaterThan: it will take subject’s object as argument, compare the calling object’s score with argument object’s score and return true if the calling object has greater score.
Create a class “Main” having main method to perform following tasks.
Create two objects of Subject class having…
arrow_forward
Assignment:The BankAccount class models an account of a customer. A BankAccount has the followinginstance variables: A unique account id sequentially assigned when the Bank Account is created. A balance which represents the amount of money in the account A date created which is the date on which the account is created.The following methods are defined in the BankAccount class: Withdraw – subtract money from the balance Deposit – add money to the balance Inquiry on:o Balanceo Account ido Date created
arrow_forward
Code the StudentAccount class according to the class diagramMethods explanation:pay(double): doubleThis method is called when a student pays an amount towards outstanding fees. The balance isreduced by the amount received. The updated balance is returned by the method.addFees(double): doubleThis method is called to increase the balance by the amount received as a parameter. The updatedbalance is returned by the method.refund(): voidThis method is called when any monies owned to the student is paid out. This method can onlyrefund a student if the balance is negative. It displays the amount to be refunded and set thebalance to zero. (Use Math.abs(double) in your output message). If there is no refund, display anappropriate message.Test your StudentAccount class by creating objects and calling the methods addFees(), pay() andrefund(). Use toString() to display the object’s data after each method called
arrow_forward
Java Assignment
Outcomes:
Student will demonstrate the ability to utilize inheritance in a Java program.
Student will demonstrate the ability to apply the IS A and HAS A relationships.
Program Specifications:
Start by watching Video Segment 16 from Dr. Colin Archibald's video series (found in the module overview). Key in the program shown in the video and make sure it works.
Then, add the following:
Animals have a Weight.
Animals have a Height.
Dog is an Animal.
Dogs have a Name.
Dogs have a Breed.
Dogs have a DOB.
Cat is an Animal
Cats have a Name.
Cats have 9 lives, so you need to keep track of the remaining lives once a cat dies.
Bird is an Animal
Birds have a wing span
Birds have a canFly which is true or false (some birds cannot fly)
Create a test class that creates one of each type of animal and displays the animal’s toString method.
Submission Requirements:
You must follow the rules from the prior assignments. UMLs and Design Tools are not required for this one.
YOU MAY…
arrow_forward
Task Performance
Amount Due
Objective:
At the end of the activity, the students should be able to:
• Apply method overloading in a program.
Procedure:
1. Develop a simple program for an individual savings account. Create two (2) classes named
AmountDue (no class modifier) and RunAmountDue (public).
2. For the AmountDue class, create three (3) overloaded methods named computeAmountDue based
on the following conditions:
With a single parameter: It represents the price of one (1) item ordered. Add 12% tax and
return the total due.
• With two (2) parameters: These represent the price of an item and the quantity ordered.
Multiply the two (2) values, add 12% tax, and return the total due.
With three (3) parameters: These represent the price of an item, the quantity ordered, and
the discount amount. Multiply the quantity and price, deduct the discount amount, add 12%
tax, and return the total due.
3. For the RunAmountDue class, import the Scanner class to be able to use the nextDouble()…
arrow_forward
Computer Science
Write a compareTo () method for this Student class.
public class Student {
private String name;
private int id;
private double gpa;
}
write it for the srudent class , best of you ablity
arrow_forward
A 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_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_forward
Screen shot please
arrow_forward
9 public class PictureViewer
10{
public static void main(String[] args)
11
12
// Step 2: Fix the syntax errors and submit it
to Codecheck to pass the test.
// Note: Do not add or remove any statements
13
//
14
15
//
Do not change the semantics of each statement
Do not add or remove any variables
Do not add or remove any objects
Magic numbers are allowed
16
17
18
//
19
//
20
// Create an object of Picture by loading an image
Picture pic = Picture("starry_night.png");
21
22
23
// Display the width and height
System.out.println("Width : " + pic.getWidth());
System.out.println("Height:
24
25
+ pic.getHeight());
%3D
26
27
// Increase the width by 50 on both sides and
// increase the height by 40 on both sides.
// Must use dw and dh when calling method grow().
int dw, dh = 40;
pic.grow(dw, dh);
28
29
30
31
32
33
// Display the width and height
System.out.println("Width :
System.out.println("Height:
34
+ pic.getWidth());
+ pic.getHeight());
35
36
37
// Draw the picture
draw();
38
39
40
//…
arrow_forward
Object adapters and class adapters each provide a unique function. These concepts are also significant due to the significance that you attach to them.
arrow_forward
#pyhton programing
topic: Introduction to Method and Designing class
Method overloading & Constructor overloading
------------------
please find the attached image
arrow_forward
public class Player { private int jerseyNumber; private int rating;
public Player(int jerseyNumber, int rating) { this.jerseyNumber = jerseyNumber; this.rating = rating; }
public int getJerseyNumber() { return jerseyNumber; }
public void setJerseyNumber(int jerseyNumber) { this.jerseyNumber = jerseyNumber; }
public int getRating() { return rating; }
public void setRating(int rating) { this.rating = rating; }
@Override public String toString() { return "Jersey number: " + jerseyNumber + ", Rating: " + rating; }}public class RosterManager { private ArrayList<Player> roster;
public RosterManager() { roster = new ArrayList<>(); }
public void addPlayer(Player player) { roster.add(player); }
public void updatePlayerRating(int jerseyNumber, int newRating) { for (Player player : roster) { if (player.getJerseyNumber() ==…
arrow_forward
#pyhton programing
topic: Introduction to Method and Designing class
Method overloading & Constructor overloading
------------------
please find the attached image
arrow_forward
Java Programming
Create your own class that illustrates the use of encapsulation. Make sure to include at least one setter and one getter for the class
arrow_forward
Java - Access Specifiers
Create a class named Circle that has attributes radius, area, and circumference and make the attributes private. Make a public method that sets the radius and a method that prints all attributes. Ask the user input for radius.
Note: Use the PI from the math functions
Inputs
A line containing an integer
10
Sample Output
Radius: 20
Area: 1256.64
Circumference: 125.66
arrow_forward
Object Oriented Programming in JAVA
You are part of a team writing classes for the different game objects in a video game. You need to write classes for the two human objects warrior and politician. A warrior has the attributes name (of type String) and speed (of type int). Speed is a measure of how fast the warrior can run and fight. A politician has the attributes name (of type String) and diplomacy (of type int). Diplomacy is the ability to outwit an adversary without using force.
From this description identify a superclass as well as two subclasses. Each of these three classes need to have a default constructor, a constructor with parameters for all the instance variables in that class (as well as any instance variables inherited from a superclass) accessor (get) and mutator (set) methods for all instance variables and a toString method. The toString method needs to return a string representation of the object. Also write a main method for each class in which that class is…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Related Questions
- fix and remove errorsarrow_forwardjava programming language You are part of a team writing classes for the different game objects in a video game. You need to write classes for the two human objects warrior and politician. A warrior has the attributes name (of type String) and speed (of type int). Speed is a measure of how fast the warrior can run and fight. A politician has the attributes name (of type String) and diplomacy (of type int). Diplomacy is the ability to outwit an adversary without using force. From this description identify a superclass as well as two subclasses. Each of these three classes need to have a default constructor, a constructor with parameters for all the instance variables in that class (as well as any instance variables inherited from a superclass) accessor (get) and mutator (set) methods for all instance variables and a toString method. The toString method needs to return a string representation of the object. Also write a main method for each class in which that class is tested – create…arrow_forwardfix code and remove errorsarrow_forward
- Library Information System Design and Testing Library Item Class Design and TestingDesign a class that holds the Library Item Information, with item name, author, publisher. Write appropriate accessor and mutator methods. Also, write a tester program(Console and GUI Program) that creates three instances/objects of the Library Items class. Extending Library Item Class Library and Book Classes: Extend the Library Item class in (1) with a Book class with data attributes for a book’s title, author, publisher and an additional attributes as number of pages, and a Boolean data attribute indicating whether there is both hard copy as well as eBook version of the book. Demonstrate Book Class in a Tester Program (Console and GUI Program) with an object of Book class.arrow_forwardUsing Visual Studio C# Language Note: not a User Inputarrow_forwardsolve with java Create a class for Subject containing the Name of the subject and score of the subject. There should be following methods: set: it will take two arguments name and score, and set the values of the attributes. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero. set: it will take one double value as argument and set the value of score only. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero. display: it will display the name and score of the subject. Like “Name : Math, Score: 99.9” getScore: it will return the value of score. greaterThan: it will take subject’s object as argument, compare the calling object’s score with argument object’s score and return true if the calling object has greater score. Create a class “Main” having main method to perform following tasks. Create two objects of Subject class having…arrow_forward
- Assignment:The BankAccount class models an account of a customer. A BankAccount has the followinginstance variables: A unique account id sequentially assigned when the Bank Account is created. A balance which represents the amount of money in the account A date created which is the date on which the account is created.The following methods are defined in the BankAccount class: Withdraw – subtract money from the balance Deposit – add money to the balance Inquiry on:o Balanceo Account ido Date createdarrow_forwardCode the StudentAccount class according to the class diagramMethods explanation:pay(double): doubleThis method is called when a student pays an amount towards outstanding fees. The balance isreduced by the amount received. The updated balance is returned by the method.addFees(double): doubleThis method is called to increase the balance by the amount received as a parameter. The updatedbalance is returned by the method.refund(): voidThis method is called when any monies owned to the student is paid out. This method can onlyrefund a student if the balance is negative. It displays the amount to be refunded and set thebalance to zero. (Use Math.abs(double) in your output message). If there is no refund, display anappropriate message.Test your StudentAccount class by creating objects and calling the methods addFees(), pay() andrefund(). Use toString() to display the object’s data after each method calledarrow_forwardJava Assignment Outcomes: Student will demonstrate the ability to utilize inheritance in a Java program. Student will demonstrate the ability to apply the IS A and HAS A relationships. Program Specifications: Start by watching Video Segment 16 from Dr. Colin Archibald's video series (found in the module overview). Key in the program shown in the video and make sure it works. Then, add the following: Animals have a Weight. Animals have a Height. Dog is an Animal. Dogs have a Name. Dogs have a Breed. Dogs have a DOB. Cat is an Animal Cats have a Name. Cats have 9 lives, so you need to keep track of the remaining lives once a cat dies. Bird is an Animal Birds have a wing span Birds have a canFly which is true or false (some birds cannot fly) Create a test class that creates one of each type of animal and displays the animal’s toString method. Submission Requirements: You must follow the rules from the prior assignments. UMLs and Design Tools are not required for this one. YOU MAY…arrow_forward
- Task Performance Amount Due Objective: At the end of the activity, the students should be able to: • Apply method overloading in a program. Procedure: 1. Develop a simple program for an individual savings account. Create two (2) classes named AmountDue (no class modifier) and RunAmountDue (public). 2. For the AmountDue class, create three (3) overloaded methods named computeAmountDue based on the following conditions: With a single parameter: It represents the price of one (1) item ordered. Add 12% tax and return the total due. • With two (2) parameters: These represent the price of an item and the quantity ordered. Multiply the two (2) values, add 12% tax, and return the total due. With three (3) parameters: These represent the price of an item, the quantity ordered, and the discount amount. Multiply the quantity and price, deduct the discount amount, add 12% tax, and return the total due. 3. For the RunAmountDue class, import the Scanner class to be able to use the nextDouble()…arrow_forwardComputer Science Write a compareTo () method for this Student class. public class Student { private String name; private int id; private double gpa; } write it for the srudent class , best of you ablityarrow_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_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT