OC Small project of Saving machine

Source: Internet
Author: User

The topic is this: To do a small assembly of computer programs, similar to the Zhongguancun save machine that.

Features that need to be implemented: 1, the main directory includes: CPU, motherboard, memory, hard disk, video card, chassis, disk display home directory, the effect can be a

2. There are several products under each part to choose from, showing these products. Two

3, each part selection is completed back to step 1, and the selected product information synchronized to step 1, three

4, the entire product to complete the selection after the effect four, the selected parts can be re-selected, the user entered the non-existent option will prompt and ask for re-entry. Five

650) this.width=650; "src=" Http://static.oschina.net/uploads/space/2015/0718/163025_ywog_2412008.png "style=" border:0px; "alt=" 163025_ywog_2412008.png "/>

Figure A


650) this.width=650; "src=" Http://static.oschina.net/uploads/space/2015/0718/163038_GOaV_2412008.png "style=" border:0px; "alt=" 163038_goav_2412008.png "/>

Figure II


650) this.width=650; "src=" Http://static.oschina.net/uploads/space/2015/0718/163047_UMIR_2412008.png "style=" border:0px; "alt=" 163047_umir_2412008.png "/>

Might



650) this.width=650; "src=" Http://static.oschina.net/uploads/space/2015/0718/163053_dn6g_2412008.png "style=" border:0px; "alt=" 163053_dn6g_2412008.png "/>

Figure Four



650) this.width=650; "src=" Http://static.oschina.net/uploads/space/2015/0718/163100_yD0U_2412008.png "style=" border:0px; "alt=" 163100_yd0u_2412008.png "/>

Figure Five

Have you got the idea of reading the topic? You can try it yourself first! I have briefly written my thoughts below. You can look at it (it's better to look at my code first).

The following marked purple font is the knowledge point in OC, you can pay attention!!





Well, probably know the requirements after we do it! Writing a program is like helping people undress, we have to layer it, and finally we can see the results we want to see!

First, we start by analyzing the requirements. This program first needs a display of information for the user to see, and the user can make a choice. So. Let's start with a new class and then let this class give us the method we need.

( Step 1, create a new class Devicesclass, add an object method to the class -(void) dispalydevices )

We have found the entrance, then the next thing is just a step-by. Object method, we first need to print one side of the message to tell the user what products we have to choose from.

( step 2, print the part information, here we can first put the part name into an array , the loop call array to achieve printing, of course, we need to initialize this array)

Users see the information can be selected, they need to choose, so we have to provide them with a selection box, select the completion, we based on the user's choice to download the corresponding product data, (here we put the data source URL into an array, according to the user input number as the array subscript call data source URL)

( Step 3, we pass a method to the user selected data source URL, download the corresponding data and stored in an array)

To implement the premise of step 3, we need a way to get the data through the URL, where we create a class, object method. and is implemented by the object method.

( Step 3.1, create a class to download and parse the data , object method downloaddataclass)

For the data obtained in step 3.1, we need a model to accept the data. So create a model. The implementation of the model we should all know. It's important to go back to the book if you don't know it.

( Step 3.1.1, Create model datamodel, model contains three attributes )

By this step, we have succeeded in half. after the data is obtained, we store the selected data in a mutable dictionary (remember to initialize) for later use, and weprint out all the available products in the user-selected part (note the two concepts of part-to-part product. Parts of a product such asCpu, part products are one of the models in this category, such as:"Model: IntelCeleronG1820(Box) ""¥ the")

( step 4, print data for all products that are available for selection)

Let the user select the product, and the user selected sequence number into an array, (why is the sequence number into an array instead of directly to the corresponding product information to deposit it?) Our product information consists of three parts: name, Price, Mark, and many times we are not convenient to call one of them, so we put the selected data into an array, then we can call this deposited number to find the corresponding product, and then will get the array, (note here will get the array, ) into a model and then call one of these three properties)

( step 5, store the selected information)

Finally, we use recursive thinking to invoke this method itself and implement loops. Then you're done!



This article from the "10533966" blog, reproduced please contact the author!

OC Small project of Saving machine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.