Question

AlphaMobile Inc. is a manufacturer of smartphones. Currently, AlphaMobile has two manufacturing locations: Singapore and New...

AlphaMobile Inc. is a manufacturer of smartphones. Currently, AlphaMobile has two manufacturing locations: Singapore and New York. The Singapore location produces the Smart4 and Smart5 models; the New York location produces that Smart5 and Smart6 models.

AlphaMobile Inc. would like to develop software that supports operations to assemble, label, and set price for each model.

*Here is my python code I implemented using python using the abstract factory design for this problem. My issue with this is that it's not printing out the model and price for the phone. How do I make my code print out the model and price?

code:

class Smart:

#Abstract Product

   def __init__(self,label,price):
       self.label = label
       self.price = price


class SmartFactoryLocation:
#Abstract Factory
  
   def construct_Smart(self,label,price):
       mobile = Smart(label,price)

   def __str__(self):
       return '{} = {}'.format(self.label,self.price)


class Singapore(SmartFactoryLocation):
#Concrete factory for Smart 4 and Smart 5
  
   def create_Smart(self):

       label = 'Baemax'

       if label == 'Baemax':
           model = 'Smart4'
           price = '$300'
           phone = Smart(model,price)
           return phone

       elif label == 'Baemax':
           model = 'Smart5'
           price = '$400'
           phone = Smart(model,price)
           return phone

       else:
           pass
          
  
class NewYork(SmartFactoryLocation):
#Concrete factory for Smart 5 and Smart 6

   label = 'Baemax'
  
   def create_Smart(self):
       if label == 'Baemax':
           model = 'Smart5'
           price = '$400'
           phone = Smart(model,price)
           return phone

       elif label == 'Baemax':
           model = 'Smart6'
           price = '$650'
           phone = Smart(model,price)
           return phone

       else:
           pass
          

##########################################################

def main():

   for phone in (Singapore(), NewYork()):
       phone = phone.create_Smart


if __name__ == "__main__":
#Runs main program
   main()

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Here is the updated code. Attach screenshot for the sample output
------------------------------------------------------------------------------------------------
class Smart:
#Abstract Product
    def __init__(self,label,price):
       self.label = label
       self.price = price

    def __str__(self):
       return '{} = {}'.format(self.label,self.price)


class SmartFactoryLocation:
#Abstract Factory
  
   def construct_Smart(self,label,price):
       mobile = Smart(label,price)

class Singapore(SmartFactoryLocation):
#Concrete factory for Smart 4 and Smart 5
    label = 'Baemax'
    def create_Smart(self):


       if Singapore.label == 'Baemax':
           model = 'Smart4'
           price = '$300'
           phone = Smart(model,price)
           return phone

       elif Singapore.label == 'Baemax':
           model = 'Smart5'
           price = '$400'
           phone = Smart(model,price)
           return phone

       else:
           return None
          
  
class NewYork(SmartFactoryLocation):
#Concrete factory for Smart 5 and Smart 6

   label = 'Baemax'
  
   def create_Smart(self):
       if NewYork.label == 'Baemax':
           model = 'Smart5'
           price = '$400'
           phone = Smart(model,price)
           return phone

       elif NewYork.label == 'Baemax':
           model = 'Smart6'
           price = '$650'
           phone = Smart(model,price)
           return phone
       else:
           pass
          

##########################################################

def main():

   for phone in (Singapore(), NewYork()):
       phone = phone.create_Smart()
       print(phone)


if __name__ == "__main__":
   main()

------------------------------------------------------------------------------------------------------------------------------------------------------------

Incase you need any help please do let me know ! I'll be happy to assist you !

thanks !

Add a comment
Know the answer?
Add Answer to:
AlphaMobile Inc. is a manufacturer of smartphones. Currently, AlphaMobile has two manufacturing locations: Singapore and New...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python 3+ Adjust the following code so the two errors below are non-present: 1. __init__() :...

    Python 3+ Adjust the following code so the two errors below are non-present: 1. __init__() : Since Pizza object don't have it's own set() datastructure, the toppings in the pizza object are manimupated from out of the object. (-1.0) 2. __eq__() : How about "self.toppings == other.toppings" rather than "self.toppings - other.toppin == set())". Code: ## Program 1 ## --------------------------------- class Pizza: def __init__(self, s='M', top=set()): self.setSize(s) self.toppings = top def setSize(self, s): self.size = s def getSize(self): return self.size...

  • Hey I have a task which consists of two part. Part A asks for writing a...

    Hey I have a task which consists of two part. Part A asks for writing a program of WORD & LINE CONCORDANCE APPLICATION in python which I have completed it. Now the second part has given 5 dictionary implementation codes namely as: (ChainingDict, OpenAddrHashDict with linear probing, OpenAddrHashDict with quadratic probing, and 2 tree-based dictionaries from lab 12 (BST-based dictionary implementation) and asks for my above program WORD & LINE CONCORDANCE APPLICATION  to use these implemented code and show the time...

  • PYTHON. Continues off another code. I don't understand this. Someone please help! Comment the lines please...

    PYTHON. Continues off another code. I don't understand this. Someone please help! Comment the lines please so I can understand LinkedList ADT: class myLinkedList:     def __init__(self):         self.__head = None         self.__tail = None         self.__size = 0     def insert(self, i, data):         if self.isEmpty():             self.__head = listNode(data)             self.__tail = self.__head         elif i <= 0:             self.__head = listNode(data, self.__head)         elif i >= self.__size:             self.__tail.setNext(listNode(data))             self.__tail = self.__tail.getNext()         else:             current = self.__getIthNode(i - 1)             current.setNext(listNode(data,...

  • PYTHON. Continues off another code(other code is below). I don't understand this. Someone please help! Comment...

    PYTHON. Continues off another code(other code is below). I don't understand this. Someone please help! Comment the lines please so I can understand. There are short and med files lengths for each the list of names/ids and then search id file. These are the input files: https://codeshare.io/aVQd46 https://codeshare.io/5M3XnR https://codeshare.io/2W684E https://codeshare.io/5RJwZ4 LinkedList ADT to store student records(code is below). Using LinkedList ADT instead of the Python List. You will need to use the Student ADT(code is below) Imports the Student class...

  • PYTHON The provided code in the ATM program is incomplete. Complete the run method of the...

    PYTHON The provided code in the ATM program is incomplete. Complete the run method of the ATM class. The program should display a message that the police will be called after a user has had three successive failures. The program should also shut down the bank when this happens. [comment]: <> (The ATM program allows a user an indefinite number of attempts to log in. Fix the program so that it displays a message that the police will be called...

  • Please write a code in python! Define and test a function named posterize. This function expects...

    Please write a code in python! Define and test a function named posterize. This function expects an image and a tuple of RGB values as arguments. The function modifies the image like the blackAndWhite function, but it uses the given RGB values instead of black. images.py import tkinter import os, os.path tk = tkinter _root = None class ImageView(tk.Canvas): def __init__(self, image, title = "New Image", autoflush=False): master = tk.Toplevel(_root) master.protocol("WM_DELETE_WINDOW", self.close) tk.Canvas.__init__(self, master, width = image.getWidth(), height = image.getHeight())...

  • In Python 3 Write a LinkedList class that has recursive implementations of the display, remove, contains,...

    In Python 3 Write a LinkedList class that has recursive implementations of the display, remove, contains, insert, and normal_list methods. You may use default arguments and/or helper functions. The file must be named: LinkedList.py Here is what I have for my code so far. The methods I need the recursive implementations for will be bolded: class Node: """ Represents a node in a linked list (parent class) """ def __init__(self, data): self.data = data self.next = None class LinkedList: """...

  • I'm trying to sort a list of students from a text file in python(3.7) with three separate sorting functions (Bubble, selection, insert) I'm not sure to why as its not working I'm going to...

    I'm trying to sort a list of students from a text file in python(3.7) with three separate sorting functions (Bubble, selection, insert) I'm not sure to why as its not working I'm going to guess its because I'm not using the swap function I built. Every time I run it though I get an error that says the following Traceback (most recent call last): File "C:/Users/tkoto/Desktop/SearchAndSortLab.py", line 146, in <module> main() File "C:/Users/tkoto/Desktop/SearchAndSortLab.py", line 122, in main studentArray.gpaSort() File "C:/Users/tkoto/Desktop/SearchAndSortLab.py",...

  • This is my assignment in Python. Please help me thank you Design type 1: # Creating an object of ...

    This is my assignment in Python. Please help me thank you Design type 1: # Creating an object of the class "Burger" theOrder = Burger() # calling the main method theOrder.main() # And the class is like: class Burger: # You may need to have a constructor def __init__(self): self._orderDict = {} self._priceBeforeTax = 0 self._priceAfterTax = 0 # you may have the tax rate also as an instance variable. But as I mentioned, you can use your # own...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT