C++代写:CS201 Class

按照题目要求实现Class,C++/Java/Python语言任选。

Class

Create a class

Make a class. It should be something really offbeat and zany, so I know it’s not a direct example from the Internet. Some totally random ideas are:

  • A crying baby and you can ask it if it is crying, make it cry, and/or ask it for a reason (maybe it has an array of reasons like “I’m hungry” etc and it returns back a reason).
  • A foodie class where you can initialize it to have a few food choices then ask it what you should eat, like custom make a burger, or order food, drink, etc. It can be anything as long as it is totally original.
  • Some imaginary or real math calculations that you invent or a game or fortune thing
  • Storing your favorite songs/playlist, or creating an artist class and then it stores and lets you add songs to it.
  • A sociopath, it could let you add sociopathic things he/she did such as Stole from mom’s wallet, on Jan 2 2020, Lied to his boss on Dec 20 2020, (etc get creative)
  • Feel good quotes, you could ask for a quote to make you grateful, it gives you random one, Ask for one to make you feel relaxed, and so on.
  • Making suggestions, for example it asks you if you are sick, then asks you about your symptoms and based on that makes a suggestion for a cure.
  • Boyfriend/girlfriend advisor, for example, asks questions then makes suggestions for the appropriate date.
  • Some sort of sports thing, or mind game

Your class should have a constructor

Make sure your class has a constructor that will set some initial properties.

If you are in Java or C++ YOUR CLASS SHOULD ACTUALLY HAVE TWO OVERLOADED CONSTRUCTORS TO PRACTICE THAT.

If you are in Python have one constructor and then make one other setter method to re-seed initial values to something different if desired.

It should have two-three additional functions that do something

Make sure your class has three functions that do something

At least one of the functions needs to (returns a value) that does something cool. At least one of your procedures (or function) should take a parameter(s).

Variables

Make sure your class has one or two variables/attributes

Data structure

Make sure your class has a simple data structure, for example,

For Python it could be just a list or tuple or set or dictionary. For example, a list that you add songs to, or a set to store coordinates, or a dictionary of info, etc. You can pick whatever data structure you want.

C/C++ it can be an array or a vector or a quete, linked list, list, etc

For Java it can be an ArrayList, or array, etc

Create an instance and demo how it can be used

Now I want you to create an instance of this class you have created, then calling it’s various methods to prove to me that everything in your class works as you expected.

Create a second instance and demo

Same thing - just create a second instance. So if you had created an instance of CryingBaby called “Suzie” now you would create a new instance called “Sarah” for example, and again, call the methods you wrote to show me you know how to create a second instance of a class and invoke its various methods.

Create the demo

You can have a menu interface to your program if you want but you don’t need to. It’s fine to just create the instances directly using hard-coded values but either way show that you can get input from the user, create your two instances, have them do something, print out results and what not. For example, ask for their favorite artist, then ask them for several songs (or just print available songs you’ve stored) by that artist, then be able to print out the songs. Or create the artist and let them choose what to play, then print out a lyric,or have them make a custom burger, or make a pizza for them by offering the topics and let them choose, or decide what fast food to order from a menu of choices. Just show your code works.

The most important thing is to write a simple class, create TWO different instances, and then be able to do something. For example, create a pizza instance for Suzie, ask her for the toppings from the choices, and store her pizza order. Then create a second pizza instance for Larry, ask for his toppings and store his pizza order. Then print both of their orders back out