




Editable code
Program
class Room:
def __init__(self, tmpRoomNum, tmpRoomType, tmpCapacity, tmpLength, tmpWidth, tmpHeight):
self.roomNum = tmpRoomNum
self.roomType = tmpRoomType
self.roomCapacity = tmpCapacity
self.length = tmpLength
self.width = tmpWidth
self.height = tmpHeight
def getRoomNum(self):
return self.roomNum
def getRoomCapacity(self):
return self.roomCapacity
def getLength(self):
return self.length
def getHeight(self):
return self.height
def getWidth(self):
return self.width
def getRoomType(self):
return self.roomType
def setRoomType(self,tmpRoomType):
self.roomType=tmpRoomType
def setRoomCapacity(self,tmpRoomCapacity):
self.roomCapacity=tmpRoomCapacity
def calArea(self):
return (self.length*self.width*self.height)
def __str__(self):
return "Room Number: "+str(self.roomNum)+"\nRoom Type: "+self.roomType+"\nRoom Capacity: "+str(self.roomCapacity)+"\nLength: "+str(self.length)+"\nHeight: "+str(self.height)+"\nWidth :"+str(self.width)+"\nArea: "+str(self.calArea())+"\n"
class RoomRoster:
def __init__(self):
self.roomCollection = []
def addRoom(self,room):
self.roomCollection.append(room)
def delRoom(self,room):
self.roomCollection.remove(room)
def __str__(self):
data = ""
for room in self.roomCollection:
data = data + str(room) +"\n"
return data
def findRoom(self,roomNum):
for room in self.roomCollection:
if(room.getRoomNum()==roomNum):
return room
return -1
def findRoomWithCapacity(self,tmpCapacity):
for room in self.roomCollection:
if(room.getRoomCapacity()==tmpCapacity):
return room
return -1
def testRoomModule():
Room_roster = RoomRoster()
room1 = Room(11,"Non-AC",2,12,10,10)
room2 = Room(12,"AC",3,12,11,11)
room3 = Room(13,"Non-AC",4,12,12,12)
print (room1)
print (room2)
print (room3)
Room_roster.addRoom(room1)
Room_roster.addRoom(room2)
Room_roster.addRoom(room3)
print("Find Room")
print(Room_roster.findRoom(11))
print("Delete Room")
Room_roster.delRoom(room2)
print(Room_roster)
testRoomModule()
using python 3: Program 14: Class with Private Attribute Collection of Objects: modRoom.py Step 1: Create...
PYTHON Task 1 Create a class called Window It has 2 public properties 1 private property 1 constructor that takes 3 arguments pass each argument to the appropriate property Task 2 In a new file import the Window class Instantiate the Window object Output the two public properties Task 3 Alter the Window class in Task 1 Add an accessor and mutator (the ability to access and change) to the private property Task 4 Create a class named Instrument Give...
Last picture is the tester program!
In this Assignment, you will create a Student class and a Faculty class, and assign them as subclasses of the superclass UHPerson. The details of these classes are in the UML diagram below: UHPerson - name : String - id : int + setName(String) : void + getName(): String + setID(int) : void + getID(): int + toString(): String Faculty Student - facultyList : ArrayList<Faculty - rank: String -office Hours : String - studentList...
Language Java Step 1: Design a class called Student. The Student class should contain the following data: firstName lastName studentID totalCredits gpa Your class should implement the “sets” and “gets” for the class. Include methods: equals, compareTo, toString. Change the toString method (from class) to put each member variable on a new line. Step 2: Write a driver program to test that Student works correctly. Test is with 3 students as given in class. Step 3: Write a “registration” program...
Using Classes/Objects Part-1 Create 3 frame/label objects Place 2 objects side-by-side on top of the screen Place the 3rd object below the top 2, spanning two columns Display a picture in one of the top 2 objects Display some text(any) in each of the other 2, or text in one and navigation buttons in the other Part-2 Load student data from database file in a list of Student class objects Add navigation features, however way you see fit Bottom-line: picture...
1. Please write the following program in Python 3. Also, please create a UML and write the test program. Please show all outputs. (The Fan class) Design a class named Fan to represent a fan. The class contains: Three constants named SLOW, MEDIUM, and FAST with the values 1, 2, and 3 to denote the fan speed. A private int data field named speed that specifies the speed of the fan. A private bool data field named on that specifies...
Problem 5: Monster Factory (10 points) (Game Dev) Create a Monster class that maintains a count of all monsters instantiated and includes a static method that generates a new random monster object. In software engineering, a method that generates new instances of classes based on configuration information is called the Factory pattern. UML Class Diagram: Monster - name: String - health: int - strength: int - xp: int + spawn(type:String): Monster + constructor (name: String, health: int, strength: int, xp:...
Write a python program using Object Oriented and do the following: 1. create class "cat" with the following properties: name, age (create constructor method: def __init__) 2. create class "adopter" with the following properties: name, phone 3. create class "transaction" with these properties: adopter, cat (above objects) cat1 = "puffy, 2" adopter1 = "Joe, 123" Test your program: Joe adopts puffy. Print: "Per Transaction 1 <joe> has adopted <puffy>" this can only be done with object oriented programming, no way...
PLEASE DO BOTH OF THESE IN PYTHON 1) Exercise #1: Design and implement class Rectangle to represent a rectangle object. The class defines the following attributes (variables) and methods: Two Class variables of type double named height and width to represent the height and width of the rectangle. Set their default values to 1.0 in the default constructor. A non-argument constructor method to create a default rectangle. Another constructor method to create a rectangle with user-specified height and width. Python...
11p
Python Language
Read the following code for oofraction. import oofraction class OOFraction: def main(): fl = oofraction.o0Fraction( 2, 5) f2 = oofraction.o0Fraction ( 1, 3) f3 = f1 + f2 print (str(3)) main() def __init__(self, Num, Den): self.mNum = Num self.mDen = Den return def_add_(self,other): num = self.mNumother.mDen + other.mNum*self.mDen den = self.mDen*other.mDen f = OOFraction(num,den) return f 1. Write the output below. def_str_(self): s = str( self.mNum )+"/" + str( self.mDen) returns 2. Write a class called wholeNum...