[SOLVED] 代写 UML XML graph Project 2 has two parts. The first is an implementation of Operation Sparty Appleseed, where you will write a program that grows trees. The second part is integration of Operation Sparty Appleseed into the Canadian Experience project so your trees can be added to the landscape of Canada. You then must create a short movie in the system.

30 $

File Name: 代写_UML_XML_graph_Project_2_has_two_parts._The_first_is_an_implementation_of_Operation_Sparty_Appleseed,_where_you_will_write_a_program_that_grows_trees._The_second_part_is_integration_of_Operation_Sparty_Appleseed_into_the_Canadian_Experience_project_so_your_trees_can_be_added_to_the_landscape_of_Canada._You_then_must_create_a_short_movie_in_the_system..zip
File Size: 3381.78 KB

SKU: 5312177812 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


Project 2 has two parts. The first is an implementation of Operation Sparty Appleseed, where you will write a program that grows trees. The second part is integration of Operation Sparty Appleseed into the Canadian Experience project so your trees can be added to the landscape of Canada. You then must create a short movie in the system.
I consider Project 2 the single most important part of this course. It is where you bring together all you have learned and produce a complete subsystem you will add to the Canadian Experience. Part 1 is relatively light, but Part 2 has two significant development components. It is your responsibility to budget your time appropriately. During the project there will be no step assignments and only one relatively short and simple design assignment, so you are being given plenty of time. But, if you wait until the last week to start the implementation you will likely not finish it.
This is a link to the project submission page.
Part 1
There one programming element due for Part 1 (a) and the Operation Sparty Appleseed design task (b) is considered an element of Part 1. Part (b) has its own page:
•a) A Prop
•b) Operation Sparty Appleseed
For (a) Add one additional graphic object that your characters can use as a prop, such as a flag, hammer, chain saw, etc. I don’t care if you make it part of an actor or create a new actor for it.
Since I am providing the starter project, there is relatively little programming in part 1. The design is the most important part!
Part 1 includes a team participation report that must be completed by all team members. See the submission page for details.
Part 2
a) Operation Sparty Appleseed Implementation
The Operation Sparty Appleseed page details the functionality of this element. Note that there are two tasks here: getting Operation Sparty Appleseed working in TreeDemo, and getting it working in CanadianExperience.
b) A Cool Movie Movie
Make a cool 30 second movie using your program. You can have your characters dance, act out a story, or whatever. You must have at least 30 keyframe locations in your presentation. Your two trees must be part of the scene and running and must start growing at different times. We reserve the right to show the better ones to the class. You must utilize the prop from (a) above.
When done with you presentation, put the .anim file in the solution folder, then submit your project. If you are submitting via the web site, be sure to put the file in the folder before you export the .zip file.
See the Submission Page for details on submitting the project.
Useful pages and information

•Operation Sparty Appleseed
•Design Questions You Must be Able to Answer
•Common Design Rejections
•Implementation of Operation Sparty Appleseed
•Integration into the Canadian Experience
•Some Common Questions
•Doubly-linked Lists
•Testing TreeLib classes
Some implementation help (available after Part 1 closes):
•Operation Sparty Appleseed Ideas and Advice
Operation Sparty Appleseed designs are due Friday, November 15 by 11:55pm. These are to be placed in an envelope and turned in to Dr. Owen or one of the course staff during the day. You may slip them under Dr. Owen’s office door (1138 Engineering) after hours. The following due dates are for the programming elements of Project 2:
Part 1 is due Saturday, November 16, 2019 at 11:55pm
Part 2 is due Friday, November 22, 2019 at 11:55pm
Your project 2 design must be approved by course staff. If they approve your design, you will receive a certificate. You must include that certificate with your design to get credit for Part 1. Be sure your team can answer the design questions before the presentation.
I suggest reading this entire assignment immediately.
The design for Operation Sparty Appleseed is a team project. All programming elements of this assignment are an individual assignment.
There are two contests associated with this project.
I am providing a Step 6 reference solution with XML save/load code and the tree library already added (available after Step 6 closes) that you can use for the project. You are welcome to use your own Step 6 solution if you wish, but you will have to add the two additional projects and save/load functionality, so I recommend using this solution as the starting point.
Project 2 Starter Project
The starter project has two executable projects: CanadianExperience and TreeDemo. To choose which one to run and debug, select it in Solution Explorer and choose Project>Set as Startup Project.
This is an executable version of TreeDemo that includes my example tree:
TreeDemo Executable
Extract to a folder and run TreeDemo.exe. Drag the slider to the right to run the ree or press the play button.
Two content pages are provided with information important to Project 2. They are:
•Adapter Classes
•The Infamous Lecture 13
Notice: If you attempt to do the project without watching the Infamous Lecture 13 video, you will probably ask a question in Interact! that will make it obvious you did not watch the Infamous Lecture 13 video.
The Movie Contest
We are holding a contest based on the Project 2 movies. The movie element of this assignment is a creative activity and deserves some recognition.
To be eligible for this contest you must have completed both the tree implementation and have integrated it into your system. A perfect implementation or integration is not required for contest eligibility, but most of the functionality must be there. You must also not have been indicated as a non-participant in the Part 1 design.
A judging panel will select the best five movies. These will be published on the class web site. The students who’s movies are selected will win the following amazing prize:
You are excused from the final exam and will receive an automatic 100% grade for that exam.
Wow! Great prize, huh?
The Tree Contest
We are holding a contest based on the Project 2 trees. You have a lot of flexibility in how you implement and parameterize your tree, so some will look more impressive than others. You are allowed to add additional images for your tree if you like beyond those supplied. However, at least two winners will be choosen who use images only in the supplied set. You are free to draw things other than images as much as you want. For example, if you choose to draw a fruit or leaf yourself instead of using an image, that will be fine. If you want to add text to your tree, that is fine.
To be eligible for this contest you must have completed both the tree implementation and have integrated it into your system. A perfect implementation or integration is not required for contest eligibility, but most of the functionality must be there. You must also not have been indicated as a non-participant in the Part 1 design.
Here is how the contest will work:
For each eligible student we will drag the TreeDemo time slider and wind sliders all of the way to the right and save an image of their tree using the seed they have as the default tree seed. The judges will not be able to see names for the images.
A judging panel will select the best five trees. These will be published on the class web site. The students who’s trees are selected will win the following amazing prize:
You are excused from the final exam and will receive an automatic 100% grade for that exam.
Wow! Great prize, huh?
The Fine Print
The judging panels will consist of Dr. Owen, the TAs, and any others we may choose to invite. The judging panels will not include undergraduate students, but may include other faculty and/or spouses.
You can only win once (you can’t get 200% on the final exam). If a student is selected in both contests, an additional winner will be chosen so at least ten students receive the prize.
We reserve the right to extend each winning cohort beyond five if we are significantly impressed with more than 5 trees or silent movies.

Example Tree and the Tree Demo application
This page describes Sparty Appleseed and how it works. There are three distinct tasks here:
•Design
•Implementation of Operation Sparty Appleseed
•Integration into the Canadian Experience
The design is a team project and is an element of Project 2 Part 1. The implementation and integration tasks can actually be done in whatever order you prefer due to the way I have designed the project.
These two pages describe the two tasks:
•Implementation of Operation Sparty Appleseed
•Integration into the Canadian Experience
These additional pages should be useful:
•Seeding a tree and CPseudoRandom
•Some Common Questions
Operation Sparty Appleseed Part 2
Once your team has completed an Operation Sparty Appleseed design, implementation is an individual element of the project.
Grading Details
The Operation Sparty Appleseed team design will be worth 20% of the project grade but, if your team does not do a good job with the design, you will lose individual points in your implementation and likely spend extra time on the implementation figuring out what your group should have worked out in design. Every team member must submit a team report once Part 1 is complete.
You will be graded on how close your implementation is to your design. A poor design will likely mean you have to deviate a lot to get this working. Even working, that will result in deducted points. For full credit, at least 50% of the functions and 75% of the attributes in your final design must have been specified in your UML. Getters and setters are not included in this count, since we usually don’t include them in the UML.
You must design your solution using good object-oriented design principles. Solutions with only one or two classes are not acceptable.
Operation Sparty Appleseed Description
This design is a variation of a Lindenmayer system, where we are expanding our tree of objects rather than just a grammar.
Add the ability for your characters to plant and grow two trees. At some point in your animation you will indicate that a tree is to start to grow. You might have your character pretend to drop a seed, for example. From there on the tree will grow. You will also include an ability to indicate in your animation when the tree’s fruit is harvested. Harvesting fruit will move them from the tree to a basket.
You will create your code in the library TreeLib. It is an additional project in your solution. You will get your tree solution working using the TreeDemo project, also an additional project in your solution. TreeDemo will allow you to work on just a tree and basket, getting them working first. Then you will integrate them into your project.
Get your solution working in TreeDemo first. It must be usable in both TreeDemo and in your animation. Course staff will test both. We will create the tree in a library that is shared between the two projects. You are not allowed to modify TreeDemo in any way.
I am providing an executable of one implementation of the tree as an example. Your implementation may look or work differently, but should have all of the same functionality.
You have a tree. The tree has limbs (branches), leaves, and fruit. The tree starts out as a single small limb. Over time it grows. At a certain point, a limb sprouts either other limbs, leaves, or fruit. The tree must be more mature before fruit appears.
There is also a basket. It appears on the screen empty. A harvest removes all fruit from the tree and moves it into the basket. (The move can be instantaneous).
Limbs are implemented as lines. Fruit and Leaves are images.
Your system must support wind blowing horizontally. Wind causes the tree to bend at every joint, not just the base!
You are required to support wind in TreeDemo, but not in the Canadian Experience. While it would certainly be cool and you are welcome to do so, if you get the animation channels done for tree seeding and harvesting, this would only add redundant work.
Be sure you read the problem description carefully. There are some obvious classes that you should not miss. Nearly all designs are rejected the first time for not having classes for the obvious things in the description.
Interface Classes
Your solution for Operation Sparty Appleseed must use these classes as an interface. This is the interface that TreeDemo expects and utilizes to draw the tree:

The starter project includes each of these classes. The only ones of these you are allowed to change are CTreeFactory and CFruit. You are not allowed to change the classes CTree, CBasket, or CTreeSeedDlg in any way! CTree and CBasket include functionality using standin-classes CTreeStandin and CBasketStandin. These classes make it possible to complete the adapter class project first, then the tree implementation if you so choose. These classes also cannot be changed in any way!
These classes are the only classes from TreeLib that you can use in the CanadianExperience project. No classes from CanadianExperience can be used in TreeLib at all! Your UML should have the classes necessary for adapting TreeLib on the left and the TreeLib classes on the right. The only lines that are allowed to cross are associations with the classes above.
You are welcome to change that class in any way you like. However, you must not change TreeDemo, which uses TreeFactory.
How can I possibly do this project if I can’t change the Tree or Basket classes?
Limbs
At any point in time, a limb has a width, height, and angle. The angle is an angle relative to its parent.
A limb is a line with Color(139, 69, 19). Assuming x,y are the location you are drawing the limb and the limb in drawn in a direction specified by angle, the code to draw the limb is:
double dx = cos(angle) * length;
double dy = sin(angle) * length;

Pen pen(Color(139, 69, 19), (REAL)width);
pen.SetEndCap(LineCapRound);
graphics->DrawLine(&pen, (REAL)x, (REAL)y,
(REAL)(x + dx), (REAL)(y + dy));
Limbs have children that are either other limbs, leaves, or fruit. The depth of a limb, leaf, or fruit is the number of parents is has plus one. For example:

Growth
Your tree limb must start at some width and length you choose. I started pretty small. Your program will work in frames. Suppose we move forward in time one frame (delta = 1/framerate time). I’ll call that value delta. Here is how you grow a tree limb:
double growRate = pow((1.0 + GrowthRate), delta);

mLength *= growRate;
mWidth *= growRate;
GrowthRate is a constant that determines how fast your tree limbs grow. Too large and the tree gets too big. Too small and the tree does not grow.
Spawning
When a limb reaches a specified length you define, it spawns. Each limb will grow two new children at that time. One child can be either a limb or a leaf. The new limb is created with a randomly selected angle relative to its parent. If the tree depth is larger than a specified size, leaves will be randomly created. I only created leaves after 7 spawnings. Leaves are also created at a random angle.
The other child can be a limb or a fruit.
The trick to making this look interesting is the random branching at each level. You will have to experiment with values to get a good looking tree. Start with just one limb and get it growing from very small to about 1/4 of the height you want your tree to be. Then decide where to spawn as it grows.
Don’t do this:
if (mLength > SpawnLength)
{
// Spawn new children
Please learn to understand context. I am not saying that you should not put spawning in your grow function. That is where it goes. I am just saying here that this particular code will fail! Spawning is part of growing and does need to be called from the Grow function.
Remember that spawning should only happen one time for a tree limb. If you put this code as it is shown here in your Grow function, it would spawn many, many times.
Since there are quite a few constants in this section of code, I am making a handbook exception and allowing literal constants here.
This is how my spawning code works. I have omitted parts of the code that would just make it too darned easy. Your solution may differ.
if (depth > 6 && ???->Random(0, 1) < 0.7){auto leaf = (create a leaf)leaf->SetAngle(???->Random(-0.2, 0.2));
AddChild(leaf);
}
else
{
auto limb = (create a limb)
limb->SetAngle(???->Random(-0.2, 0.2));
AddChild(limb);
}

if (depth > 8 && ???->Random(0, 1) < 0.1){auto fruit = (create a fruit)fruit->SetAngle(???->Random(-0.2, 0.2));
AddChild(fruit);
}
else
{
auto limb = (create a limb)
limb->SetAngle(???->Random(-1.5, 1.5));
AddChild(limb);
}
You are welcome to modify the spawning if you want to make a nicer tree.
Leaves
A few different leaf options are provided in the images directory: leaf.png, leaf2.png, and leaf3.png. You can choose whichever you like. The example solution uses leaf3.png. They can be at any angle. Leaves should also grow, but only until they are full size, then they should stop growing.
Fruit
A Fruit are the images apple.png, grapes.png, and orange.png in the images directory. You can choose whichever you like. The example solution uses orange.png. Fruit should always hang down, though there should be some random rotation of the fruit so it is not hanging directly down. Fruit should also grow, but only until they are full size, then they should stop growing.
Basket
There are two basket images: basket.png and basket-front.png. Draw basket.png first, then draw the contents of the basket, then draw basket-front.png. That will make it look like the fruit is in the basket. Place the fruit at random locations in the basket.
Dialog Box
There is an included class CTreeSeedDlg that you will use to choose a tree seeding. This class is easy to use. To choose a tree seeding, you would do:
CTreeSeedDlg dlg(tree);
if (dlg.DoModal() == IDOK) {
// A new seed has been set
}
In this case, tree is of type: std::shared_ptr .
Unacceptable Solutions
If your design has duplicate code or more than one duplicate member variable in two or more classes, it is not acceptable. For example, if you have two classes with the code to draw a bitmap, your design has a problem.
Design submissions that do not have a design-approved certificate will not be accepted.

You will need to integrate your tree and basket with your system.
Since TreeLib currently includes stand-in graphics for the tree, this can be done before or after implementation of your tree. If you do this before implementing the tree, you can later implement the tree and it will automatically appear!
Since you can’t change CTree, you will have to adapt it to make it a drawable. You are to create an encapsulation adapter class to make the tree be a drawable in your system. You will find detail on the Adapter pattern in Chapter 4 of the Gang of Four book. That book refers to this type of adapter as an adapter that relies on object composition.
You also must make an adapter class for CBasket, also making it a drawable.
You must provide a way to choose the tree using CTreeSeedDlg. This way you can see different tree. Your solution must extend the XML save/load to include the tree seed number and other details so that a loaded tree will work the same way as when it was created.
You are only allowed to use these classes in the CanadianExperience project:
•CTree
•CBasket
•CFruit
•CTreeFactory
•CTreeSeedDlg
If you try to use any other classes you create, they will not link, anyway, due to the way I have constructed the project.
Chapters 4 pages 139-150
You are expected to read that chapter and implement a tree adapter class. The adapter will be a new class derived from CDrawable. It will be a drawable class, since it will draw the tree.
You must be able to animate a point when the tree starts to grow. All of this must work with the timeline so you can create a presentation where the characters interact with the trees. You may choose how to place each tree, be it dragging it around, or whatever. You are not required to make the tree moveable, though you may if you wish to or you can hard code the position if you like. You must support two trees and one basket.
Notice: Your adapter class must completely hide all elements of the CTree and CBasket classes. You are especially not to do something like this, for example:
public:
CTree *GetTree() {return mTree;}
Doing so completely voids the purpose of the adapter class. If you do this, you will not have an adapter class anymore, which will be decidely harmful to your grade.
Important: You may not modify CTree in any way!
The interface for the supplied classes is documented in the code as Doxygen comments.
Notes and Hints – Tree and Basket Adapters
Creating a tree and basket is easy using the factory class:
CTreeFactory factory;
std::shared_ptr tree = factory.CreateTree();

std::shared_ptr basket = factory.CreateBasket();
For some reason, people seem to have decided that making the factory a member variable is part of the solution to this problem. Making factories a member variable is a very bad practice and you will lose points for this part of the assignment if you do so!
A CTree object by default draws at location (0, 0). You can move it by calling SetRootLocation. You can also move it and scale it using Gdiplus functions if you prefer. Consider the CTree position just a slave of the position of the drawable. It is easy to just set the position before you draw. Here is an example of how I would draw the tree if I was creating a private inheritance adapter (which you are not):
void CTreeDrawable::Draw(Gdiplus::Graphics *graphics)
{
CTree::SetRootLocation(mPlacedPosition.X, mPlacedPosition.Y);
CTree::DrawTree(graphics);
}
If you decide you don’t like the size of the trees in the Canadian Experience, the easiest solution is to just use the following code to place and scale it before you draw each time. Then your drawable uses the same position information as all other drawables. This may make any animation easier to implement. Here is an example of how I would draw the trees at a smaller scale if I was creating a private inheritance adapter (which you are not):
void CTreeDrawable::Draw(Gdiplus::Graphics *graphics)
{
float scale = 0.3f;

auto save = graphics->Save();
graphics->TranslateTransform((float)mPlacedPosition.X,
(float)mPlacedPosition.Y);
graphics->ScaleTransform(scale, scale);
CTree::DrawTree(graphics);
graphics->Restore(save);
}
The call to graphics->Save() saves the current status of the graphics context. You call that so you can restore it after you are done. TranslateTransform says everything after this point will be moved by this amount. Since the tree by default draws at (0,0), this moves it to mPlacedPosition. If your tree graphics are a bit too large to draw in the CanadianExperience, the call to ScaleTransform scales the graphics to 30%. Then you call the function to draw.
After you are done, you call Restore(save). That cancels out the Translate and Scale operations for future drawing.
**Your code will be different**
You’ll need to create some mechanism to store the tree seednumbers and when the trees start growing when you save the XML.
The Dialog Box
You must support CTreeSeedDlg for each of your trees. How you bring up that dialog box is up to you. You can have menu options or you can double-click or whatever you want to do.
Bringing up the dialog box is easy:
CTreeSeedDlg dlg(tree);
if (dlg.DoModal() == IDOK)
{
// A tree seed has been changed
}
In this example, tree is of type std::shared_ptr .

Advice:
I’m using this page to post some suggestions and advice on implementing Operation Sparty Appleseed. Some of the things here you may not have thought about or your design may not have anticipated. I’m also giving some code suggestions where I think you might waste a lot of time figuring out how to do something. Hopefully, this will make things go smoother.
Advice on Development Process
Develop the tree in TreeDemo. Trying to develop it in CanadianExperience will be very hard to do. Simple programs that just allow you to test a system make them much easier to develop.
Try to do small steps and get something working. I like to make plans and create a list of tasks on paper or a whiteboard. One of my favorite activities in the world is erasing a task! Smaller tasks means more to erase. Yah! My task lists generally start with smaller tasks and then get larger and more complex in the list. As I knock something off the front, I rewrite the list expanding something further down.
Example development order (this is only a suggestion, there are many ways to get this going):
I’ve seen students waste many hours trying to get code working that was not even being called. Be sure your functions are being called first, then you can build from there.
•Create your actual tree class and change the factory to create it. Create empty functions and ensure they are being called by setting breakpoints. TreeDemo should no longer show the standin tree.
•Create your limb class and create a root limb.
•Get it to draw the root limb line in the right direction.
•Make the one root limb grow.
•Spawn child limbs only!
•Ensure you can draw forward and backward and the tree is consistent.
•Add support for drawing images (see below). Get this working by drawing a leave from the tree draw function. Ensure you can scale, rotate, and place the image when you draw it.
•Add the class for a tree image part and the class for a leaf.
•Get it spawning leaves.
•Add support for the fruit. I would not worry about harvest just yet.
•Get it spawning fruit.
•Try to ensure the tree works the way you want it to work at this point in time.
•Add support for harvest. Ensure it works by ensure the fruit disappears and is returned by the harvest function.
•Add the basket. There’s really very little for the code basket.
•Wind. Notice how I left this for last. Get everything else working first, then add wind to your system.
Things I would not do:
Don’t create all of the classes at once. It may seem like a good idea since you have your UML, but you may find you need to adjust some parameters and add some functions. Do not expect your UML to be perfect. If you create all of the classes at once you may have to change several you are not working on while you get your code working.
Don’t Load Images Multiple Times
Does your Leaf constructor look something like this?
CLeaf::CLeaf() : CTreeImagePart(LeafFilename)
{

}
Seems like that would make sense, right? After all, that’s the way we did the aquarium. Here’s the problem. If you are passing the filename like this, that means you must be loading the image from a file in CTreeImagePart. A tree many have thousands of leaves. This will require thousands of loadings of an image from disk. It will so be slow it will probably be just about useless.
Instead, load the images in one place. You can create a class or I just loaded mine in CTreeActual. Then my CLeaf Constructor looks something like this:
CLeaf::CLeaf(CTreeActual *tree, int depth) :
CTreeImagePart(tree, depth, tree->GetLeaf())
{
}
Notice that I also pass a poitner to my actual tree class to all tree parts. That’s super handy, since it allows you to easily access things like images and the random number generator.
A Reliable and Reproduceable SetTreeFrame
An important element of growing the tree is to handle a new frame. You would think you might do something like this:
/**
* Set the current tree frame
* param frame Frame number
*/
void CTreeActual::SetTreeFrame(int frame)
{
mRoot->Grow(frame – mCurrentFrame);
mCurrentFrame = frame;
}
While this may work, if you are dragging the time slider you may see very different results. And, this won’t work to go backwards in time. To get reliable results, you should always grow your tree one frame at a time. Here’s the SetTreeFrame function I used:
/**
* Set the current tree frame
* param frame Frame number
*/
void CTreeActual::SetTreeFrame(int frame)
{
if (frame < mCurrentFrame){Reset();}while (mCurrentFrame < frame) {mCurrentFrame++;mRoot->Grow();
}
}
Notice how I have a Reset function that resets the random number generator and tree to the initial state. Also, notice how I grow one frame at a time. If mCurrentFrame is 5 and frame is 7, this will call Grow two times. Another hint: Don’t try to reset the root limb. Just create a new one. And, don’t duplicate code. Call Reset from your tree constructor.
You may have different parameters to your Grow function or have named it differently.
Draw functions
Most every group assumed a position attribute for tree parts and a draw function something like this:
void CTreeLimb::Draw(Gdiplus::Graphics *graphics)
{
}
While there are ways to make this work, it is a lot easier to implement the draw if you pass the rotation and location of the parent to the function (or use getters to get them from the parent):
void CTreeLimb::Draw(Gdiplus::Graphics *graphics, double angle, double x, double y)
{
}
This is saying that I should draw this limb starting at x,y and that the parent’s angle is in the parameter angle. Then if you have an angle for this limb, the actual angle we draw is that angle plus the parent angle:
void CTreeLimb::Draw(Gdiplus::Graphics *graphics, double angle, double x, double y)
{
double useAngle = angle + mAngle;
This becomes the angle for the part. If the parent limb started at 400, 350 and has angle 0.75 radians and the child limb has angle 0.3 radians (branches to the right), the child should draw at 0.75 + 0.3 =1.05 radians.
If you do it this way, wind will be much easier to implement!
Understand what sin and cos do
We’ve all had trig, right? We should know what the sin and cos functions do. If you know the starting point for a limb and the angle to draw it, use sin and cos to compute the direction of the tree as an x,y vector:
double dx = cos(useAngle) * mLength;
double dy = sin(useAngle) * mLength;
Note that what I pass to children is this:
child->Draw(graphics, useAngle, x + dx, y + dy);
The children grow from the limb end.
Consider Adding An Image Class
I did see an image class in a few designs. Consider creating a class that does nothing other than loading and drawing an image. Mine looks like this:
/**
* Class that represents an image used by our system.
*/
class CTreeImage
{
public:
CTreeImage(const std::wstring name);

/// Default constructor/disabled
CTreeImage() = delete;

/// Copy constructor/disabled
CTreeImage(const CTreeImage &) = delete;

/// Destructor
virtual ~CTreeImage() {}

void CTreeImage::Draw(Gdiplus::Graphics *graphics, double angle, double scale, double x, double y);

private:
std::shared_ptr mImage; ///< The part image};Then, lots of classes become very easy. CBasketActual has two images, a back and front image. I just make them member variables that are allocated objects of type CTreeImage:private:/// The image of the basketstd::shared_ptr mBasketImage1;

/// The image of the front of the basket
std::shared_ptr mBasketImage2;
These are loaded in the constructor:
/// The image of the entire basket
const std::wstring BasketImage = L”images/basket.png”;

/// The image for the front only of the basket
const std::wstring BasketFrontImage = L”images/basket-front.png”;

/**
* Constructor
*/
CBasketActual::CBasketActual()
{
mBasketImage1 = std::make_shared (BasketImage);
mBasketImage2 = std::make_shared (BasketFrontImage);

mRandom.Seed((int)time(nullptr));
}
Then drawing each image is one line of code. You can use this same class in CImagePart as well. My function CImagePart::Draw is only two lines long.
This works much better than trying to inherit from CTreeImage, especially for the Basket, which uses two different images. Also, my program only ever constructs four CTreeImage objects for the two basket images, the fruit, and the leaf.
Simplicity Rules
Try to write simple code. While this project may seem complex, there is actually a fairly small amount of code. Be sure you understand how an up-call works or you’ll have a tough time. My CTreeFruit has only five functions including the constructor and destructor. Every function is one line long. My CTreeLeaf actually only has a constructor and destructor. The work is all done in CTreeImagePart. CTreeImagePart only has five functions as well. Even my tree limb, with it’s ability to grow and spawn, has only six functions. The largest function in the whole program, CTreeLimb::Grow() easily fits on my screen.

The starter project is a Visual Studio solution with four different projects:
•CanadianExperience – The Step 5/6 project we all know and love
•Testing – The testing project
•TreeLib – A library project that your tree code will all go in
•TreeDemo – A project you can use to test your tree implementation prior to integrating it
All of your code for the tree implementation will go in TreeLib. You will add your design classes to that project.
TreeLib initially has implementations of Tree and Basket that present stand-in graphics. You will replace this functionality when you implement the project. You are not to use CTreeStandin or CBasketStandin in your implementation at all. They exist do it is possible to do the integration into the rest of the system prior to implementing the tree.
We will get questions about how you can possibly change the functionality if you are not allowed to change CTree and CBasket. After all, if you can’t change what they do, how can you implement your tree or your basket? Your team should be able to come up with an answer for that.
TreeDemo is a demonstration program. You can use TreeDemo to get your tree completely working without any integration with the Canadian Experience project. The fact that there is a defined interface makes that possible.
If you want to use Unit Testing, you will not have to add anything from TreeDemo to the link dependencies. The entire library has already been added, so that is done for you.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 UML XML graph Project 2 has two parts. The first is an implementation of Operation Sparty Appleseed, where you will write a program that grows trees. The second part is integration of Operation Sparty Appleseed into the Canadian Experience project so your trees can be added to the landscape of Canada. You then must create a short movie in the system.
30 $