rotator
.py
keyboard_arrow_up
School
Drexel University *
*We aren’t endorsed by this school
Course
380
Subject
Computer Science
Date
Oct 30, 2023
Type
py
Pages
3
Uploaded by DeanMetalChimpanzee3
import sys
DEFAULT_STATE = '12345|1234 |12354'
class Action:
def __init__(self, type, x1, y1, x2, y2, dx):
self.type = type
self.x1 = int(x1)
self.y1 = int(y1)
self.x2 = int(x2)
self.y2 = int(y2)
self.dx = int(dx)
def __str__(self):
if self.type == "rotate":
return f"rotate({self.x1},{self.dx})"
else:
return f"slide({self.x1},{self.y1},{self.x2},{self.y2})"
class State:
def __init__(self, string):
self.state_string = string
self.rows = self.state_string.split("|")
def __str__(self):
return "|".join(self.rows)
def __eq__(self, state):
return str(state) == "|".join(self.rows)
def clone(self):
return State(str(self))
def is_goal(self):
for i in range (len(self.rows[0])):
for j in range (1, len(self.rows)):
if self.rows[0][i] == " " or self.rows[j][i] == " ":
continue
if self.rows[0][i] != self.rows[j][i]:
return False
return True
def actions(self):
actions = []
for x in range(len(self.rows)):
actions.append(Action("rotate", x, -1, -1, -1, -1))
actions.append(Action("rotate", x, -1, -1, -1, 1))
for x in range(len(self.rows)):
for y in range(len(self.rows[0])):
if self.rows[x][y] == " ":
if (x - 1) >= 0:
actions.append(Action("slide", y, x-1, y, x,
-1))
if (x + 1) < len(self.rows):
actions.append(Action("slide", y, x+1, y, x,
-1))
return actions
def execute(self, action):
if action.type == "slide":
value1 = self.rows[action.y1][action.x1]
value2 = self.rows[action.y2][action.x2]
s1 = list(self.rows[action.y1])
s1[action.x1] = value2
s2 = list(self.rows[action.y2])
s2[action.x2] = value1
self.rows[action.y1] = "".join(s1)
self.rows[action.y2] = "".join(s2)
else:
if action.dx == 1:
s = list(self.rows[action.x1])
s = [s[-1]] + s[:-1]
self.rows[action.x1] = "".join(s)
else:
s = list(self.rows[action.x1])
s = s[1:] + [s[0]]
self.rows[action.x1] = "".join(s)
if __name__ == "__main__":
cmd = sys.argv[1]
if cmd:
state_string = sys.argv[2] if len(sys.argv) > 2 else DEFAULT_STATE
state = State(state_string)
if cmd == "print":
print(str(state))
elif cmd == "goal":
print(state.is_goal())
elif cmd == "actions":
for actions in state.actions():
print(str(actions))
elif cmd.startswith("walk"):
states = []
done = False
x = 1
curr_state = state.clone()
while x:
for state in states:
if curr_state == state:
done = True
break
if done == True:
break
print(curr_state)
states.append(curr_state)
new = curr_state.clone()
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
User-defined Class:You will design and implement your own data class. The class will store data that has been read asuser input from the keyboard (see Getting Input below), and provide necessary operations. As thedata stored relates to monetary change, the class should be named Change. The class requires atleast 2 instance variables for the name of a person and the coin change amount to be given to thatperson. You may also wish to use 4 instance variables to represent amounts for each of the 4 coindenominations (see Client Class below). There should be no need for more than these instancevariables. However, if you wish to use more instance variables, you must provide legitimatejustification for their usage in the internal and external documentation.Your class will need to have at least a default constructor, and a constructor with two parameters:one parameter being a name and the other a coin amount. Your class should also provide appropriateget and set methods for client usage. Other…
arrow_forward
Program - Python
This is my program for a horse race class (Problem below code)
class Race: def __init__(self,name,time): self.name = name self.time = time self.entries = []
class Entrant: def __init__(self,horsename,jockeyname): self.horsename = horsename self.jockeyname = jockeyname
race1 = Race('RACE 1','10:00 AM May 12, 2021')race2 = Race('RACE 2','11:00 AM May 12, 2021')race3 = Race('RACE 3','12:00 PM May 12, 2021')
race1.entries.append(Entrant('Misty Spirit','John Valazquez'))race1.entries.append(Entrant('Frankly I’m Kidding','Mike E Smith'))
race2.entries.append(Entrant('Rage against the Machine','Russell Baze'))
race3.entries.append(Entrant('Secretariat','Bill Shoemaker'))race3.entries.append(Entrant('Man o War','David A Gall'))race3.entries.append(Entrant('Seabiscuit','Angel Cordero Jr'))
print(race1.name, race1.time)for entry in race1.entries: print('Horse:',entry.horsename) print('Jockey:',entry.jockeyname) print()…
arrow_forward
classname.py -> using "sys.argv"
● Create a program called classname.py. The program should define a class called person that has one method called hello, and one attribute called name, which represents the name of the person. ● The hello method should print the following string to the screen: ‘My name is ____ and I am a _____’ where: ○ The first blank should be the name attribute ○ The second blank should be the name of the class ○ The above blanks should NOT be manually printed (ex. print(‘My name is Greg and I am a person’)) ● After defining the class, there are three things you must do: 1. Instantiate an object of the class 2. Run the hello method of the instantiated object a. (e.g., Greg.hello()) 3. For grading purposes, you must also print the name of the class so I can be sure you’ve created a class a. (The expected output is )
arrow_forward
build a student class
implement the student class with the following instance variables:
* id
* firstName
*lastName
*dateOfBirth
* Major
create an __init__ function adn initialize all the fields
make the "major" an option field and set a default value to "undefined"
create a setter and getter function for all these five variables
create another function: "print_student_info()" which prints 5 pieces of information: id, first name, last name, date of birth, and major. Make sure to have proper formatting done for printing these 5 things.
Use the student class
Task 1: create an empty list named "all_students"
Task 2: create a variable named "id" and initialize it to 100 (some default value to start with, next id would be 101)
Task 3: ask the user for input "How many students:"
Task 4: Now run a for loop based on that input number and do the following things for each iteration:
- get input of student's first name, last name, date of birth, and major
- user should be able to skip the…
arrow_forward
C++ Dont include a breed.cc file. Use only 4 files.
READ ME
PetsBreed ClassCreate a Breed class with the following:
Member VariablesCreate the following private member variables, all of type std::string:
species_breed_name_color_ConstructorsCreate a default constructor for Breed that sets its species_ to "Dog", breed_name_ to "Pug", and color_ to "Fawn".Create a non-default constructor that receives a std::string for species_, breed_name_, and color_; in that order. The values from the constructor should appropriately assign the member variables.Accessors and MutatorsCreate accessors and mutators for all member variables, following the naming conventions covered in class. e.g. for species_, name the accessor Species, and the mutator SetSpecies.
Pet ClassCreate a Pet class with the following:
Member VariablesCreate the following private member variables:
std::string name_Breed breed_double weight_ConstructorsCreate a default constructor for Pet that sets its name to "Doug" and weight to…
arrow_forward
Problem C
• -3: method consonants() had more than one loop
• -3: method initials () had more than one loop
• -3: at least one method used nested loops
arrow_forward
2. The MyInteger Class
Problem Description:
Design a class named MyInteger. The class contains:
n
[]
[]
A private int data field named value that stores the int
value represented by this object.
A constructor that creates a MyInteger object for the
specified int value.
A get method that returns the int value.
Methods isEven () and isOdd () that return true if the value
is even or odd respectively.
Static methods isEven (int) and isOdd (int) that return true
if the specified value is even or odd respectively.
Static methods isEven (MyInteger) and isOdd (MyInteger) that
return true if the specified value is even or odd
respectively.
Methods equals (int) and equals (MyInteger) that return true
if the value in the object is equal to the specified value.
Implement the class. Write a client program that tests all
methods in the class.
arrow_forward
In Python: Write a class named Pet, which should have the following data attributes:
_ _name (for the name of a pet)
_ _animal_type (for the type of animal that a pet is. Example values are 'Dog','Cat', and 'Bird')
_ _age (for the pets age)
The Pet class should have an _ _init_ _ method that creates these attributes. It should also have the following methods:
set_nameThis method assigns a value to the _ _name field
set_animal_typeThis method assigns a value to the _ _animal_type field
set_ageThis method assignsa value to the _ _age field
get_nameThis method assignsa value to the _ _name field
get_animal_typeThis method assignsa value to the _ _animal_type field
get_ageThis method assignsa value to the _ _age field
Once you have written the class, write a program that creates an object of the class and prompts the user to enter the name, type and age of his or her pet. This data should be stored as the objects attributes. Use the objects accessor methods to retrieve the pets…
arrow_forward
Python Programming2. Write a class named Pet, which should have the following data attributes:(a). __name (for the name of a pet)__animal_type (for the type of animal that a pet is. Example values are ‘Dog’, ‘Cat’, and ‘Bird’)__age (for the pet’s age)The Pet class should have an __init__ method that creates these attributes. It should also have the following methods:(b). set_name: This method assigns a value to the __name field.set_animal_type: This method assigns a value to the __animal_type field.set_age: This method assigns a value to the __age field.get_name: This method returns the value of the __name field.get_animal_type: This method returns the value of the __animal_type field.get_age: This method returns the value of the __age field.
arrow_forward
Please code in python
Create a program with two classes – the person class and the student The person class has the following properties:
first name (first_name),
last name (last_name)
street address (address)
city (city)
zip code (zip)
The class has the following methods:
get_full_name, which returns the full name of a person
get_full_address, which return
greeting, returns a greeting message.
The class should provide accessor and mutator for each property
The class should override the __str__ method to return the state of the object.
Create a child class called student which has a property named graduation year (graduation_year) and major.
Provide accessor and mutator for each property of its own
It inherits all the properties and methods of the person parent class as well.
Create a test program that
Create an object of the person class and print the full name of a person.
Create an object of the person class and print…
arrow_forward
Python program for this project:
Patient Charges
Write a class named Patient that has attributes for the following data:
First name, middle name, and last name
Address, city, state, and ZIP code
Phone number
Name and phone number of emergency contact
The Patient class’s _ _init_ _ method should accept an argument for each attribute. The Patient class should also have accessor and mutator methods for each attribute.
Next, write a class named Procedure that represents a medical procedure that has been performed on a patient. The Procedure class should have attributes for the following data:
Name of the procedure
Date of the procedure
Name of the practitioner who performed the procedure
Charges for the procedure
The Procedure class’s _ _init_ _ method should accept an argument for each attribute. The Procedure class should also have accessor and mutator methods for each attribute.
Next, write a program that creates an instance of the Patient class, initialized with sample data.
Then,…
arrow_forward
Make Album in c++
You are going to develop a new class named Album. This class will has (at a minimum) teh following attributes and features:
Attributes:
Album Title
Artist Name
Array of song names (Track Listing)
Array of track lengths (decide on a unit)
At most there can be 20 songs on an album.
Behaviors:
Default and at least one argumented constructor
Appropriate getters for attributes
bool addTrack(string name, type duration) - adds track to album. You decide type on duration. Make sure you document what dis is.
getAlbumLength() - method dat returns total length of album matching watever units / type you decide.
getAlbumLength_string() - method dat returns total length of album in mm:ss format string. I would suggest using you're other getLength function here.
string shuffleAlbum(int n) - method dat returns a formatted string made up of n random tracks from teh album.
The string will be in the format [1] track_name (mm:ss), [2] track_name (mm:ss)...
Well formatted print()…
arrow_forward
Make Album in c++
You are going to develop a new class named Album. This class will has (at a minimum) teh following attributes and features:
Attributes:
Album Title
Artist Name
Array of song names (Track Listing)
Array of track lengths (decide on a unit)
At most there can be 20 songs on an album.
Behaviors:
Default and at least one argumented constructor
Appropriate getters for attributes
bool addTrack(string name, type duration) - adds track to album. You decide type on duration. Make sure you document what dis is.
getAlbumLength() - method dat returns total length of album matching watever units / type you decide.
getAlbumLength_string() - method dat returns total length of album in mm:ss format string. I would suggest using you're other getLength function here.
string shuffleAlbum(int n) - method dat returns a formatted string made up of n random tracks from teh album.
The string will be in the format [1] track_name (mm:ss), [2] track_name (mm:ss)...
Well formatted print()…
arrow_forward
Create a class Distance with feet and inches as a private dada members. Feet has int type and inches has float type. Create getdist & showdist functions which take values from user and then display these values respectively. Create another class Sign with sign as a private data member. Sign has a char data type. Class sign is inherited with distance class. Create getdist and showdist function to get values from user and then display all values. Create default & arrguments constructor also.
Add a static data member named objCount, initialize it to 0 using scope resolution operator outside the class, add a function in the class to print the value of objCount.
arrow_forward
solve in python
Street ClassStep 1:• Create a class to store information about a street:• Instance variables should include:• the street name• the length of the street (in km)• the number of cars that travel the street per day• the condition of the street (“poor”, “fair”, or “good”).• Write a constructor (__init__), that takes four arguments corresponding tothe instance variables and creates one Street instance.
Street ClassStep 2:• Add additional methods:• __str__• Should return a string with the Street information neatly-formatted, as in:Elm is 4.10 km long, sees 3000 cars per day, and is in poor condition.• compare:• This method should compare one Street to another, with the Street the method is calledon being compared to a second Street passed to a parameter.• Return True or False, indicating whether the first street needs repairs more urgently thanthe second.• Streets in “poor” condition need repairs more urgently than streets in “fair” condition, whichneed repairs more…
arrow_forward
#Python IDLE:
#Below is my Pizza class ,how would I write the function described in the attached image,based on this class?
# The Pizza class should have two attributes(data items):
class Pizza:
# The Pizza class should have the following methods/operators):
# __init__ -
# constructs a Pizza of a given size (defaults to ‘M’)
# and with a given set of toppings (defaults to empty set).
def __init__(self, size='M', toppings=set()):
self.size = size
self.toppings = toppings
# setSize – set pizza size to one of ‘S’,’M’or ‘L’
def setSize(self, size):
self.size = size
# getSize – returns size
def getSize(self):
return self.size
# addTopping – adds a topping to the pizza, no duplicates, i.e., adding ‘pepperoni’ twice only adds it once
def addTopping(self, topping):
self.toppings.add(topping)
# removeTopping – removes a topping from the pizza
def removeTopping(self, topping):…
arrow_forward
#this is python programing
#topic: OOP
Question 2
Design a class called Flower with the instance variables so that after executing the following line of code the desired result shown in the output box will be printed. [You are not allowed to change the code below]
#Write your class code here
flower1 = Flower()
flower1.name="Rose"
flower1.color="Red"
flower1.num_of_petal=6
print("Name of this flower:", flower1.name)
print("Color of this flower:",flower1.color)
print("Number of petal:",flower1.num_of_petal)
print(“=====================”)
flower2 = Flower()
flower2.name="Orchid"
flower2.color="Purple"
flower2.num_of_petal=4
print("Name of this flower:",flower2.name)
print("Color of this flower:",flower2.color)
print ("Number of petal:",flower2. num_of_petal)
#Write the code for subtask 2 and 3 here
Output:
Name of this flower: Rose
Color of this flower: Red
Number of petal: 6
=====================
Name of this flower: Orchid
Color of this flower: Purple…
arrow_forward
please help me asap
use python
help me asap
Implement the design of the Student and Lawyer class derived from Person class so that the following code generates the output below:class Person: def __init__(self, name, contact): self.name = name self.contact = contact def __str__(self): s = f"Name: {self.name}\nContact: {self.contact}" return s#Write your code herejohn_cena = Student("John Cena", "9752325", 100005, "CSE")john_cena.add_courses("CSE111 Programming Language II", "CSE230 Discrete Mathematics", "EEE101 Electrical Circuits 1")print("1.=========================================================")print(john_cena)print("2.=========================================================")john_cena.show_course_list("CSE")print("3.=========================================================")john_cena.show_course_list("ECE")print("4.=========================================================")john_cena.add_courses("ARC101 Design I: Basic…
arrow_forward
C:/Users/r1821655/CLionProjects/untitled/sequence.cpp:48:5: error: return type specification for constructor invalidtemplate <class Item>class sequence{public:// TYPEDEFS and MEMBER SP2020typedef Item value_type;typedef std::size_t size_type;static const size_type CAPACITY = 10;// CONSTRUCTORsequence();// MODIFICATION MEMBER FUNCTIONSvoid start();void end();void advance();void move_back();void add(const value_type& entry);void remove_current();// CONSTANT MEMBER FUNCTIONSsize_type size() const;bool is_item() const;value_type current() const;private:value_type data[CAPACITY];size_type used;size_type current_index;};}
48 | void sequence<Item>::sequence() : used(0), current_index(0) { } | ^~~~
line 47 template<class Item>
line 48 void sequence<Item>::sequence() : used(0), current_index(0) { }
arrow_forward
JAVA PROGRAM
arrow_forward
Java program
arrow_forward
In java language
arrow_forward
Programming Exercise 11-2
dateType.h file provided
#ifndef date_H
#define date_H
class dateType
{
public:
void setDate(int month, int day, int year);
//Function to set the date.
//The member variables dMonth, dDay, and dYear are set
//according to the parameters
//Postcondition: dMonth = month; dDay = day;
// dYear = year
int getDay() const;
//Function to return the day.
//Postcondition: The value of dDay is returned.
int getMonth() const;
//Function to return the month.
//Postcondition: The value of dMonth is returned.
int getYear() const;
//Function to return the year.
//Postcondition: The value of dYear is returned.
void printDate() const;
//Function to output the date in the form mm-dd-yyyy.
bool isLeapYear();
//Function to determine whether the year is a leap year.
dateType(int month = 1, int day = 1, int year = 1900);
//Constructor to…
arrow_forward
#destructor
class Person:
def __init__(self, name):
self.name = name
print(f'Person {self.name} is created.")
def __del_(self):
print(f'Person {self.name} is destroyed.")
p1 = Person("John")
del p1
#deleting object by del build in function
output
P2 = Person("Eme") #destructor will be called automattically for p2
arrow_forward
# Pets## Breed ClassCreate a `Breed` class with the following:
### Member VariablesCreate the following private member variables, all of type `std::string`: 1. `species_`2. `breed_name_`3. `color_`
### Constructors1. Create a default constructor for `Breed` that sets its `species_` to `"Dog"`, `breed_name_` to `"Chihuahua"`, and `color_` to `"Fawn"`.2. Create a non-default constructor that receives a `std::string` for `species_`, `breed_name_`, and `color_`; in that order. The values from the constructor should appropriately assign the member variables.
### Accessors and MutatorsCreate accessors and mutators for all member variables, following the naming conventions covered in class. e.g. for species_, name the accessor `Species`, and the mutator `SetSpecies`.
## Pet ClassCreate a `Pet` class with the following:
### Member VariablesCreate the following private member variables:1. `std::string name_`2. `Breed breed_` 3. `double weight_`
### Constructors1. Create a default constructor…
arrow_forward
C++ Dont include a breed.cc file
READ ME
PetsBreed ClassCreate a Breed class with the following:
Member VariablesCreate the following private member variables, all of type std::string:
species_breed_name_color_ConstructorsCreate a default constructor for Breed that sets its species_ to "Dog", breed_name_ to "Pug", and color_ to "Fawn".Create a non-default constructor that receives a std::string for species_, breed_name_, and color_; in that order. The values from the constructor should appropriately assign the member variables.Accessors and MutatorsCreate accessors and mutators for all member variables, following the naming conventions covered in class. e.g. for species_, name the accessor Species, and the mutator SetSpecies.
Pet ClassCreate a Pet class with the following:
Member VariablesCreate the following private member variables:
std::string name_Breed breed_double weight_ConstructorsCreate a default constructor for Pet that sets its name to "Doug" and weight to 15.6. The Breed…
arrow_forward
Programming Language= PYTHON
1. Pet Class Write a class named Pet, which should have the following data attributes:
• _ _name (for the name of a pet)
• _ _animal_type (for the type of animal that a pet is. Example values are ‘Dog’, ‘Cat’, and ‘Bird’)
• _ _age (for the pet’s age) The Pet class should have an _ _init_ _ method that creates these attributes. It should also have the following methods:
• set_name This method assigns a value to the _ _name field.
• set_animal_type This method assigns a value to the _ _animal_type field.
• set_age This method assigns a value to the _ _age field.
• get_name This method returns the value of the _ _ name field.
• get_animal_type This method returns the value of the _ _animal_type field.
• get_age This method returns the value of the _ _age field.
Once you have written the class, write a program that creates an object of the class and prompts the user to enter the name, type, and age of his or her pet. This data should be stored as the object’s…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Related Questions
- User-defined Class:You will design and implement your own data class. The class will store data that has been read asuser input from the keyboard (see Getting Input below), and provide necessary operations. As thedata stored relates to monetary change, the class should be named Change. The class requires atleast 2 instance variables for the name of a person and the coin change amount to be given to thatperson. You may also wish to use 4 instance variables to represent amounts for each of the 4 coindenominations (see Client Class below). There should be no need for more than these instancevariables. However, if you wish to use more instance variables, you must provide legitimatejustification for their usage in the internal and external documentation.Your class will need to have at least a default constructor, and a constructor with two parameters:one parameter being a name and the other a coin amount. Your class should also provide appropriateget and set methods for client usage. Other…arrow_forwardProgram - Python This is my program for a horse race class (Problem below code) class Race: def __init__(self,name,time): self.name = name self.time = time self.entries = [] class Entrant: def __init__(self,horsename,jockeyname): self.horsename = horsename self.jockeyname = jockeyname race1 = Race('RACE 1','10:00 AM May 12, 2021')race2 = Race('RACE 2','11:00 AM May 12, 2021')race3 = Race('RACE 3','12:00 PM May 12, 2021') race1.entries.append(Entrant('Misty Spirit','John Valazquez'))race1.entries.append(Entrant('Frankly I’m Kidding','Mike E Smith')) race2.entries.append(Entrant('Rage against the Machine','Russell Baze')) race3.entries.append(Entrant('Secretariat','Bill Shoemaker'))race3.entries.append(Entrant('Man o War','David A Gall'))race3.entries.append(Entrant('Seabiscuit','Angel Cordero Jr')) print(race1.name, race1.time)for entry in race1.entries: print('Horse:',entry.horsename) print('Jockey:',entry.jockeyname) print()…arrow_forwardclassname.py -> using "sys.argv" ● Create a program called classname.py. The program should define a class called person that has one method called hello, and one attribute called name, which represents the name of the person. ● The hello method should print the following string to the screen: ‘My name is ____ and I am a _____’ where: ○ The first blank should be the name attribute ○ The second blank should be the name of the class ○ The above blanks should NOT be manually printed (ex. print(‘My name is Greg and I am a person’)) ● After defining the class, there are three things you must do: 1. Instantiate an object of the class 2. Run the hello method of the instantiated object a. (e.g., Greg.hello()) 3. For grading purposes, you must also print the name of the class so I can be sure you’ve created a class a. (The expected output is )arrow_forward
- build a student class implement the student class with the following instance variables: * id * firstName *lastName *dateOfBirth * Major create an __init__ function adn initialize all the fields make the "major" an option field and set a default value to "undefined" create a setter and getter function for all these five variables create another function: "print_student_info()" which prints 5 pieces of information: id, first name, last name, date of birth, and major. Make sure to have proper formatting done for printing these 5 things. Use the student class Task 1: create an empty list named "all_students" Task 2: create a variable named "id" and initialize it to 100 (some default value to start with, next id would be 101) Task 3: ask the user for input "How many students:" Task 4: Now run a for loop based on that input number and do the following things for each iteration: - get input of student's first name, last name, date of birth, and major - user should be able to skip the…arrow_forwardC++ Dont include a breed.cc file. Use only 4 files. READ ME PetsBreed ClassCreate a Breed class with the following: Member VariablesCreate the following private member variables, all of type std::string: species_breed_name_color_ConstructorsCreate a default constructor for Breed that sets its species_ to "Dog", breed_name_ to "Pug", and color_ to "Fawn".Create a non-default constructor that receives a std::string for species_, breed_name_, and color_; in that order. The values from the constructor should appropriately assign the member variables.Accessors and MutatorsCreate accessors and mutators for all member variables, following the naming conventions covered in class. e.g. for species_, name the accessor Species, and the mutator SetSpecies. Pet ClassCreate a Pet class with the following: Member VariablesCreate the following private member variables: std::string name_Breed breed_double weight_ConstructorsCreate a default constructor for Pet that sets its name to "Doug" and weight to…arrow_forwardProblem C • -3: method consonants() had more than one loop • -3: method initials () had more than one loop • -3: at least one method used nested loopsarrow_forward
- 2. The MyInteger Class Problem Description: Design a class named MyInteger. The class contains: n [] [] A private int data field named value that stores the int value represented by this object. A constructor that creates a MyInteger object for the specified int value. A get method that returns the int value. Methods isEven () and isOdd () that return true if the value is even or odd respectively. Static methods isEven (int) and isOdd (int) that return true if the specified value is even or odd respectively. Static methods isEven (MyInteger) and isOdd (MyInteger) that return true if the specified value is even or odd respectively. Methods equals (int) and equals (MyInteger) that return true if the value in the object is equal to the specified value. Implement the class. Write a client program that tests all methods in the class.arrow_forwardIn Python: Write a class named Pet, which should have the following data attributes: _ _name (for the name of a pet) _ _animal_type (for the type of animal that a pet is. Example values are 'Dog','Cat', and 'Bird') _ _age (for the pets age) The Pet class should have an _ _init_ _ method that creates these attributes. It should also have the following methods: set_nameThis method assigns a value to the _ _name field set_animal_typeThis method assigns a value to the _ _animal_type field set_ageThis method assignsa value to the _ _age field get_nameThis method assignsa value to the _ _name field get_animal_typeThis method assignsa value to the _ _animal_type field get_ageThis method assignsa value to the _ _age field Once you have written the class, write a program that creates an object of the class and prompts the user to enter the name, type and age of his or her pet. This data should be stored as the objects attributes. Use the objects accessor methods to retrieve the pets…arrow_forwardPython Programming2. Write a class named Pet, which should have the following data attributes:(a). __name (for the name of a pet)__animal_type (for the type of animal that a pet is. Example values are ‘Dog’, ‘Cat’, and ‘Bird’)__age (for the pet’s age)The Pet class should have an __init__ method that creates these attributes. It should also have the following methods:(b). set_name: This method assigns a value to the __name field.set_animal_type: This method assigns a value to the __animal_type field.set_age: This method assigns a value to the __age field.get_name: This method returns the value of the __name field.get_animal_type: This method returns the value of the __animal_type field.get_age: This method returns the value of the __age field.arrow_forward
- Please code in python Create a program with two classes – the person class and the student The person class has the following properties: first name (first_name), last name (last_name) street address (address) city (city) zip code (zip) The class has the following methods: get_full_name, which returns the full name of a person get_full_address, which return greeting, returns a greeting message. The class should provide accessor and mutator for each property The class should override the __str__ method to return the state of the object. Create a child class called student which has a property named graduation year (graduation_year) and major. Provide accessor and mutator for each property of its own It inherits all the properties and methods of the person parent class as well. Create a test program that Create an object of the person class and print the full name of a person. Create an object of the person class and print…arrow_forwardPython program for this project: Patient Charges Write a class named Patient that has attributes for the following data: First name, middle name, and last name Address, city, state, and ZIP code Phone number Name and phone number of emergency contact The Patient class’s _ _init_ _ method should accept an argument for each attribute. The Patient class should also have accessor and mutator methods for each attribute. Next, write a class named Procedure that represents a medical procedure that has been performed on a patient. The Procedure class should have attributes for the following data: Name of the procedure Date of the procedure Name of the practitioner who performed the procedure Charges for the procedure The Procedure class’s _ _init_ _ method should accept an argument for each attribute. The Procedure class should also have accessor and mutator methods for each attribute. Next, write a program that creates an instance of the Patient class, initialized with sample data. Then,…arrow_forwardMake Album in c++ You are going to develop a new class named Album. This class will has (at a minimum) teh following attributes and features: Attributes: Album Title Artist Name Array of song names (Track Listing) Array of track lengths (decide on a unit) At most there can be 20 songs on an album. Behaviors: Default and at least one argumented constructor Appropriate getters for attributes bool addTrack(string name, type duration) - adds track to album. You decide type on duration. Make sure you document what dis is. getAlbumLength() - method dat returns total length of album matching watever units / type you decide. getAlbumLength_string() - method dat returns total length of album in mm:ss format string. I would suggest using you're other getLength function here. string shuffleAlbum(int n) - method dat returns a formatted string made up of n random tracks from teh album. The string will be in the format [1] track_name (mm:ss), [2] track_name (mm:ss)... Well formatted print()…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Browse Popular Homework Q&A
Q: r = 4 sin 0 – 2 cos e
by finding a Cartesian equation of the curve.
Find a polar equation for the…
Q: According to the following cell designation, which specie undergoes oxidation? Sn |
Sn+2|| MnO₂ |…
Q: Vermont Instruments manufactures two models of calculators. The fiancé model is the Fin-X and the…
Q: Consider the following functions.
f(x) = x² and g(x) = √√x +3
Step 2 of 2: Find the formula for…
Q: In each of the following, find the equation of theplane normal to the given vector N and…
Q: How many isomers of the formula C4H8C12 are there?
a. 4 b. 6
2
3
c. 8
d. 9
Q: A 500-N force is applied to a bent plate as shown. Determine
(a) an equivalent force-couple system…
Q: Gary and Georgeann have the following objectives:
If Gary predeceases Georgeann, to provide her…
Q: Listed below are the conference designations of teams that won a certain annual tournament, where…
Q: THIS IS THE FORMULA
- b ± √b²-4ac
2a
your work for
X =
2
- 2x²+3x = 2
THIS IS THE EQUATION
Q: Freefight Airlines is presently operating at 70 percent of capacity. Management of the airline is…
Q: The following chemical reaction takes place in aqueous solution:
FeSO4(aq)+Na₂S(aq) →…
Q: 24'
24'
I-
30'
-I
B
A
ーエー
26'
-I
-I
-1
WDL = 100 psf
WLL = 50 psf.
Use LRFD
4p50
Q: 7. Given quarter-circular gate AB is 9-ft wide is hinged at A. Determine the
contact force between…
Q: What is the goal of circuit theory?
Q: CH2CH2CH2CH2
I
OH
I
OH
Н
С
+ H2O
Q: Suppose that the total revenue function is given by
R(x) = 47x
and that the total cost function is…
Q: 2. The clamp of the given figure is used to hold a cover in place. The screw of the clamp
has a…
Q: I Consider an analog signal xa(t) = sin(250πt) + sin(400πt) + sin(750πt).
(a) What is the Nyquist…
Q: can you write part b out and attach a photo it is unreadable in this format. also please address…
Q: (a) Determine the total area under the standard normal curve to the left of z= -2 or to the right of…
Q: Find the remainder when 819054 is divided by 13.
Q: Find a vector equation with parameter tt for the line of intersection of the planes x+y+z=4x+y+z=4…
Q: 4.67 Determine the reactions at B and D when b
=
.C
hp
80 N
A
D
75 mm
250 mm
C
90 mm-
B
60 mm.
Q: I a) Design a noninverting amplifier with a gain of 100 using ideal op amps and practical
values of…