高级方法概念FlexibleOrder [英] Advanced Method Concepts FlexibleOrder

查看:57
本文介绍了高级方法概念FlexibleOrder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我需要帮助完成我正在做的家庭作业。首先,我将展示我的说明,然后我将展示我到目前为止的代码。



我的指示 -



为Potsie's Pottery创建一个名为FlexibleOrder的C#程序,该程序接受用户从附表中的选项中选择。



允许用户输入整数项目编号或字符串描述。将用户的条目传递给两个重载的GetDetails()方法之一,然后显示返回的字符串。



接受整数的方法版本查找描述和价格返回包含所有订单详细信息的字符串。



接受字符串描述的版本会查找商品编号和价格,并返回包含所有订单详细信息的字符串。



如果找不到该项,方法将返回相应的消息。




好​​的这里是我的代码我收到错误,我不知道下一步该做什么 -



Hello all, I need help with a homework assignment that I am working on. First I will show my instructions, and then I will show the code I have so far.

My instructions -

create a C# program for Potsie's Pottery named FlexibleOrder that accepts a user's choice from the options in the accompanying table.

Allow the user to enter either an integer item number or a string description. Pass the user's entry to one of two overloaded GetDetails() methods and then display the returned string.

The method version that accepts an integer looks up the description and price and returns a string with all the order details.

The version that accepts a string description looks up the item number and price and returns a string with all the order details.

The methods return an appropriate message if the item is not found.


Ok here is the code I have I'm getting errors and I don't know what to do next -

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FlexibleOrder   

{
    class ItemNumber  
    {
        public string Description { get; set; }

        public int Price { get; set; }

        public int ItemNum { get; set; }
    }
    class Description
    {
        public Description(string name)
        {
        }

        public void Add("plate,cup,bowl,vase,planter,statue".Description);
        {
        }

        public Student GetDetails(string name)
        {
            return new Order();
        }
    }
}

推荐答案

我认为老实说你需要把一两步,看看你有什么。然后将其与您迄今为止查看的代码示例进行比较。



问题在于:

I think to be honest that you need to take as step or two back, and look at what you have got there. Then compare that to the code samples you have been looking at up to now.

The problem is here:
public void Add("plate,cup,bowl,vase,planter,statue".Description);
{
}



这不是方法声明,它是在方法中执行的代码,但是没有方法将其包含在内代码,并在末尾塞满了一对括号...



你到底想要做什么我不太确定,但肯定是是不对的,而且根本不适合你 - 你需要看看你应该怎么做,并尝试将它与你的东西进行比较。



谢谢你的时间和回复。我正试图传递用户的条目,就像我的指示说的那样。这就是为什么我把文字变成粗体。我该怎么做才能解决这个问题?这是令人沮丧的哈哈。



很难说:我建议你重新开始尝试分阶段进行。首先尝试从用户那里获得一些输入 - 你现在还没有 - 然后担心以后如何处理它。在开始时忽略大部分任务,并尝试做你知道该怎么做的部分,你应该能够毫无问题地从用户那里得到输入,因为为了达到这个目的,你必须先做好几次! :笑:



从小处开始,稍微迈出几步。当您对整个任务不那么困惑时,步幅可以变得更大。


That isn't a method declaration, it's code to be executed inside a method, but without a method round it to contain the code, and with a pair of brackets stuffed on the end...

Exactly what you are trying to do here I'm not quite sure, but certainly that isn't right, and it's too fundamental to just fix for you - you need to look at how you should do things and try comparing that against what you have.

"Thanks for you're time and reply. I am trying to pass the user's entry just like my instructions say. Thats why I made the text bold. What should I do to fix that problem? This is frustrating lol."

Difficult to say: I would suggest that you start again and try to do it in stages. Begin by trying to actually get some input from the user - which you aren't at the moment - then worry about what to do with it later. Ignore most of the task at the beginning, and try to do the bits you do know how to do, and you should be able to get input from the user without problems, because to get this far you must have done it several times before! :laugh:

Start small, take little steps. The strides can get bigger later, when you are less confused by the whole task.


对您的解决方案必须的外观做一些概述可能会有所帮助根据你手头的信息。



1.你有一个表:让我们假设该表是一般形式,其中每一行代表一个库存项目用户可能会订购,每行的列条目会为您提供商品ID编号,描述,价格,库存信息等。



a。取决于该表的组织方式(键是什么,哪些项在哪些列中)确切地如何编写函数以返回项目描述当然会有所不同。



2.你知道你需要写两个GetDetails函数:每个函数都会返回一个Item Description或一个not in stock消息。



a。其中一个函数将接受库存ID(让我们假设一个整数)参数:



私有字符串GetDetails(int itemID)

{< br $> b $ b}



b。另一个函数将接受一个字符串参数:



private string GetDetails(string itemDescription)

{

}



.NET允许相同的函数名称,只要参数列表不同即可。这两个函数定义是否与你的课程讲师完全匹配过载是你应该检查的东西。



所以,现在,你可以专注于实现你的两个GetDetails函数,并且还考虑返回的字符串的格式。



如果使用字符串查找表中的项目,可能会考虑输入字符串的可能部分匹配和表中包含的项目的描述字符串的情况:



假设用户查找:Betty Boop Shoes



而且,在表格中有几个项目的描述包括Betty Boop这两个词,其中两个包括Shoes:这个词



1.项目123Betty Boop将成为这款鳄鱼细跟高跟鞋的美女。



2.项目124Betty Boop是这些舒适的天鹅绒鞋中的tres elegante apre diner,镶嵌着莱茵斯顿es。



你想对所有三个单词进行独立搜索吗?或者,搜索短语是否需要在表中的项目描述中作为一个整体进行匹配?您的搜索在搜索时是将搜索条件或项目描述转换为所有小写还是大写?



3.最后,在某些时候您将有一个搜索字段,用户键入某些文本,然后激活搜索功能:在搜索功能的开头,您需要确定用户是否输入了数字,单词或短语。因此,您的任务是在搜索字段中检查用户的输入,确定其类型,并调用相应的GetDetails()函数。



解决问题的策略通过将问题分解为独立的块然后继续在编程中经常被称为分而治之。
It may be helpful to do some outlining of what your solution must look like based on the information you have at hand.

1. you have a "table:" let's assume that table is of the general form where each row represents an inventory item the user might order, and the column entry for each row give you the item id number, description, price, in-stock information, etc.

a. depending on how that table is organized (what the keys are, what items are in which columns) exactly how you write your functions to return the item description will, of course, vary.

2. you know you need to write two GetDetails functions: each will return an Item Description, or a "not in stock" message.

a. one of the functions will accept an inventory id (let's assume an integer) parameter:

private string GetDetails(int itemID)
{
}

b. the other function will accept a string parameter:

private string GetDetails(string itemDescription)
{
}

.NET permits identical function names as long as the parameter lists are different. Whether those two function definitions exactly match what your course instructor means by "over-loaded" is something you should check out.

So, now, you can focus on implementing your two GetDetails functions, and, also, think about the format of the string returned.

In the case of looking up an item in the Table using a string, you might consider the case of possible partial matches of the input string and the description string for the item contained in the Table:

Suppose the user looked for: "Betty Boop Shoes"

And, in the Table were several items whose description included the phrase "Betty Boop," and two that included the word "Shoes:"

1. item 123 "Betty Boop is set to be the belle of the ball in these crocodile stiletto high-heeled shoes."

2. item 124 "Betty Boop is tres elegante apre diner in these comfortable velvet shoes, inlaid with rhinestones."

Would you want to do an independent search for all three words ? Or, would the search phrase need to be matched, as a whole, in the item description in the Table ? Should your search convert either the search-terms or the item description in the Table to all lower- or upper-case while searching ?

3. finally, at some point you are going to have a search field where the user types in some text and then activates a search function: at the start of the search function you are going to need to figure out if the user entered a number, or a word, or phrase. So you have the task of examining the user's input in the search field, determining its Type, and calling the appropriate GetDetails() function.

The strategy of problem-solving by breaking the problem into independent "chunks" and then proceeding is often referred to in programming as "divide and conquer."


这篇关于高级方法概念FlexibleOrder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆