25.7k views
5 votes
design a class named computer that holds the make, model, and amount of memory of a computer. include methods to set the values for each data field, and include a method that displays all the values for each field. create a diagram and write pseudocode that defines the class.

1 Answer

4 votes

The UML (Unified Modeling Language) provides a visual representation of the Computer class.

// Constructor (optional, depending on the language)

Computer():

make = ""

model = ""

memory = 0

// Method to set the make of the computer

setMake(m: String):

make = m

// Method to set the model of the computer

setModel(m: String):

model = m

// Method to set the amount of memory in the computer

setMemory(m: int):

memory = m

// Method to display all values for each field

displayInfo():

print("Make: ", make)

print("Model: ", model)

print("Memory: ", memory)

design a class named computer that holds the make, model, and amount of memory of-example-1
User Vikram Bose
by
9.1k points