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...
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:...
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...
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...
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...
In Java please! Problem You will be using the point class discussed in class to create a Rectangle class. You also need to have a driver class that tests your rectangle. Requirements You must implement the 3 classes in the class diagram below and use the same naming and data types. Following is a description of what each method does. Point Rectangle RectangleDriver - x: int - top Left: Point + main(args: String[) - y: int - width: int +...
Java code for the following inheritance hierarchy figure.. 1. Create class Point, with two private instance variables x and y that represented for the coordinates for a point. Provide constructor for initialising two instance variables. Provide set and get methods for each instance variable, Provide toString method to return formatted string for a point coordinates. 2. Create class Circle, its inheritance from Point. Provide a integer private radius instance variable. Provide constructor to initialise the center coordinates and radius for...
C++C++ Exercise 1: Create a class Resource. The class should have: a) Two private variables status and writeTo representing integer value either 0 or 1. b) One default constructor that initializes the status and writeTo to zero. c) One single parameterized constructor to initialize the writeTo variable. d) Two constant accessor functions per class that return the values of status e) Two mutator functions per class that set the values of status and writeTo One output (member) function that outputs...