我不是在寻找具体的答案,而是更多的指导。 [英] I am not looking for specific answers but more of some guidence.

查看:49
本文介绍了我不是在寻找具体的答案,而是更多的指导。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面我将发布我必须做的事情。我已经创建了3个类但是,这几乎就是我所获得的。我真的不知道该怎么办我在课堂上真的很挣扎。任何帮助都会受到赞赏。



设置:

您将使用C#控制台应用程序创建名为FirstnameLastname_CE01的新Visual Studio项目模板。

评分:

请参阅本标题的CE:01标签,了解此作业的评分程序。

可交付成果:

您将使用以下内容压缩并上传名为FirstnameLastname_CE01.zip的文件,其名称如下:

Project - 包含整个项目的文件夹以及包含所有文件的文件夹构建项目(csproj,.cs文件,App.config和Properties文件夹)。



确保第一次上传正确的项目和所有必需的文件只允许一次提交。如果上传了错误的文件,将不会有额外的时间或考虑。

说明:

对于今天的实验室,您将创建通过构造函数相互交互的类,方法和成员变量。类的布局如下所述,也在下面提供的UML图中描述。您将在整个应用程序中包含打印语句,以记录运行应用程序时发生的情况。

使用以下指南来完成此应用程序:

类别

创建3个类

他们可以但不必称为ClassA,ClassB和ClassC。

每个类应该有3个原始成员变量,每个变量都有一种独特的类型

(例如int,bool,string或其他组合)。

每个类应该有与其他类不同的成员类型组合。

每个类应该有2个额外的成员变量,其类型是另外两个类。

(例如,ClassA包含ClassB和ClassC成员等)

构造函数

每个类都应该有一个默认构造函数,只需打印: 'ClassName'默认构造函数到控制台以指示它何时发生。

每个类应该有一个构造函数,其中有3个参数,其类型与该类的3个成员变量相匹配。

在构造函数内部,成员变量值应设置为参数值。

这些应该打印'ClassName'3参数构造函数。

每个类应该有2个额外的构造函数。

每个人都应该有一个参数,这是另外两个类中的一个。

(例如,ClassA将有一个接收ClassB而另一个接收ClassC)。

应将相同类型的成员变量设置为这两个构造函数的参数值。

这些应该打印''ClassName',带参数:'ParameterType'。

附加方法

每个类应包含一个参数为另外两个班级之一

(例如,ClassA将是ClassB或ClassC)。

然后该方法应该实例化你没有用作参数的类

(例如,如果ClassB是参数,那么实例化ClassC)。

实例化该类时,使用与此方法具有相同参数的构造函数

(例如,如果ClassB是此函数的参数,则使用ClassB为的构造函数的参数)。

新对象应存储在当前类的成员变量中。

该方法应该使用参数'ParameterType'打印''ClassName'方法



我尝试过:



我唯一做的就是创建课程,我对接下来要做什么感到难过。我想我只是在努力做下一步该做什么。

Below I will post what I have to do. I have already created the 3 classes but, that is pretty much as far as I have gotten. I do not really know what to do I am really struggling in my class. Any help woulde be appreciated.

Setup:
You will be creating a new Visual Studio project named "FirstnameLastname_CE01" using the C# Console Application template.
Grading:
Please refer to the CE:01 tab of this rubric to understand the grading procedures for this assignment.
Deliverables:
You will compress and upload a file named "FirstnameLastname_CE01.zip" with the following contents with the following names:
Project - Folder containing your entire project and all files necessary to build the project(csproj, .cs files, App.config, and Properties folder).

Be sure to upload the correct project and all required files the first time as only one submission will be allowed. No extra time or consideration will be given if the wrong files are uploaded.
Instructions:
For today's lab you will be creating classes that all interact with each other through constructors, methods, and member variables. The layout of the classes is described below and also in a UML diagram provided below. You will include print statements throughout the application to document what happens when the application is run.
Use the following guidelines to complete this application:
Classes
Create 3 classes
They can, but don’t have to, be called ClassA, ClassB, and ClassC.
Each class should have 3 primitive member variables each with a unique type
(Ex. int, bool, string or some other combination).
Each class should have a different combination of member types from the other classes.
Each class should have 2 additional member variables whose types are the other two classes.
(Ex. ClassA contains a ClassB and ClassC member, etc.)
Constructors
Each class should have a default constructor that simply prints: " ‘ClassName’ default constructor" to the console to indicate when it occurs.
Each class should have a constructor that has 3 parameters with types matching the 3 member variables of that class.
Inside of the constructor the member variable values should be set to the parameter values.
These should print " ‘ClassName’ 3 parameter constructor".
Each class should have 2 additional constructors.
Each one should have a single parameter that is one of the other two classes.
(Ex. ClassA would have one that takes in a ClassB and another that takes in a ClassC).
The member variable of the same type should be set to the parameter’s value for both of these constructors.
These should print " ‘ClassName’ with parameter: ‘ParameterType’ ".
Additional Methods
Each class should contain a method whose parameter is one of the other two classes
(Ex. ClassA would be ClassB or ClassC).
The method should then instantiate the class that you did not use as the parameter
(Ex. If ClassB is the parameter then instantiate ClassC).
When instantiating that class use the constructor that takes in the same parameter as this method
(Ex. If ClassB was the parameter of this function then use a constructor that ClassB is the parameter for).
The new object should be stored in a member variable of the current class.
The method should print " ‘ClassName’ method with parameter ‘ParameterType’ "

What I have tried:

The only thing I have done is create the class and I am stumped as to what to do next. I guess i am just struggling with what to do next.

推荐答案

而不是说找一个新的班级或讲师,我的意思是......让我起来吧去一所新的大学,轻松愉快,你需要真正考虑编程是否是你想要做的事业。分配的任务真的很简单,也许你在思考它?无论哪种方式,它都非常直接。



是的,这项任务是愚蠢的,在现实世界的编程中完全没有基础。我唯一可以看到的是传递方法是方法重载/构造函数重载是一件事。除此之外,它教你比其他任何东西更坏的习惯。



我把ClassA,ClassB,ClassC作为某些东西的对象(人,地址) ,车辆)这样的参数有一些熟悉的名称,而不是ClassA。我还使用反射来获取类名,因为这个赋值是愚蠢的,并且不想去每个构造函数并且硬编码类名。



看到这可能是一个入门课程,我会饶恕你会采取不同的做法,但希望你拿这个代码,研究它,看看你能不能掌握正在发生的事情。但有一件事,如果你无法自学或自己学习掌握新的/具有挑战性的概念......仔细看看你的专业,它不会比这更容易。



另外,不要把这当作我交给你作业的答案。如果您查看此代码并且不知道发生了什么,请在评论中提出问题,我将很乐意澄清导致您被卡住的一切



Rather than say find a new class or instructor, which i mean...let me just up and go to a new college, easy peasy, you need to really think about if programming is what you want to do as a career. The task assigned is really quite simple, maybe you are over thinking it? Either way, it is pretty straight forward.

Yes this assignment is stupid and has absolutely no base at all in real world programming. The only thing i can see this conveying is method overloading/constructor overloading is a thing. Other than that, its teaching you more bad habits than anything else.

I made up ClassA, ClassB, ClassC to be objects of some "thing" (person, address, vehicle) so that way the parameters have some familiar name other than "ClassA". I also used reflection to get class names because this assignment is dumb and didn't want to go to each constructor and hard code the class names.

Seeing how this is probably an introductory course, i'll spare you with what i would do differently but hopefully you take this code, study it and see if you can grasp what is going on. But one thing, if you are unable to teach yourself or learn on your own to grasp new/challenging concepts...take a good hard look at your major, it doesn't get any easier than this.

Also, don't think of this as me handing you the answers to your homework. If you look at this code and have no idea what is going on, ask questions in the comments and i'll be happy to clarify whatever is causing you to get stuck

static void Main(string[] args)
        {
            Console.WriteLine("Default constructors");
            var classa = new ClassA();
            var classb = new ClassB();
            var classc = new ClassC();

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Pass the class into the constructor");

            var classa2 = new ClassA(classb);
            var classa3 = new ClassA(classc);
            var classb2 = new ClassB(classa);
            var classb3 = new ClassB(classc);
            var classc2 = new ClassC(classa);
            var classc3 = new ClassC(classb);

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Pass in individual properties to constructor");

            var classa4 = new ClassA("myname", 99, true);
            var classb4 = new ClassB("100 main street", 1111, true);
            var classc4 = new ClassC("Ford", 2005, true);

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Run print methods");
            
            classa.Print(classb);
            classb.Print(classc);
            classc.Print(classa);

            Console.ReadLine();
        }
    }

    public class ClassA
    {
        public ClassA()
        {
            var classname = this.GetType().Name;

            Console.WriteLine("'{0}' default constructor", classname);
        }

        public ClassA(string name, int age, bool ismale)
        {
            var classname = this.GetType().Name;

            Console.WriteLine("'{0}' three parameter constructor", classname);

            this.Name = name;
            this.Age = age;
            this.IsMale = ismale;
        }

        public ClassA(ClassB address)
        {
            var classname = this.GetType().Name;
            var paramname = address.GetType().Name;

            Console.WriteLine("'{0}' with parameter: '{1}'", classname, paramname);

            this.Address = address;
        }

        public ClassA(ClassC vehicle)
        {
            var classname = this.GetType().Name;
            var paramname = vehicle.GetType().Name;

            Console.WriteLine("'{0}' with parameter: '{1}'", classname, paramname);

            this.Vehicle = vehicle;
        }

        public void Print(ClassB classb)
        {
            this.Vehicle = new ClassC(classb);
        }

        public string Name { get; set; }
        public int Age { get; set; }
        public bool IsMale { get; set; }

        public ClassB Address { get; set; }
        public ClassC Vehicle { get; set; }
    }

    public class ClassB
    {
        public ClassB()
        {
            var classname = this.GetType().Name;

            Console.WriteLine("'{0}' default constructor", classname);
        }

        public ClassB(string address, int zipcode, bool isinternational)
        {
            var classname = this.GetType().Name;

            Console.WriteLine("'{0}' three parameter constructor", classname);

            this.Address = address;
            this.ZipCode = zipcode;
            this.IsInternaltional = isinternational;
        }

        public ClassB(ClassA person)
        {
            var classname = this.GetType().Name;
            var paramname = person.GetType().Name;

            Console.WriteLine("'{0}' with parameter: '{1}'", classname, paramname);

            this.Person = person;
        }

        public ClassB(ClassC vehicle)
        {
            var classname = this.GetType().Name;
            var paramname = vehicle.GetType().Name;

            Console.WriteLine("'{0}' with parameter: '{1}'", classname, paramname);

            this.Vehicle = vehicle;
        }

        public void Print(ClassC classc)
        {
            this.Person = new ClassA(classc);
        }

        public string Address { get; set; }
        public int ZipCode { get; set; }
        public bool IsInternaltional { get; set; }

        public ClassA Person { get; set; }
        public ClassC Vehicle { get; set; }
    }

    public class ClassC
    {
        public ClassC()
        {
            var classname = this.GetType().Name;

            Console.WriteLine("'{0}' default constructor", classname);
        }

        public ClassC(string vehmake, int vehyear, bool istruck)
        {
            var classname = this.GetType().Name;

            Console.WriteLine("'{0}' three parameter constructor", classname);

            this.VehicleMake = vehmake;
            this.VehicleYear = vehyear;
            this.IsTruck = istruck;
        }

        public ClassC(ClassA person)
        {
            var classname = this.GetType().Name;
            var paramname = person.GetType().Name;

            Console.WriteLine("'{0}' with parameter: '{1}'", classname, paramname);

            this.Person = person;
        }

        public ClassC(ClassB address)
        {
            var classname = this.GetType().Name;
            var paramname = address.GetType().Name;

            Console.WriteLine("'{0}' with parameter: '{1}'", classname, paramname);

            this.Address = address;
        }

        public void Print(ClassA classa)
        {
            this.Address = new ClassB(classa);
        }

        public string VehicleMake { get; set; }
        public int VehicleYear { get; set; }
        public bool IsTruck { get; set; }

        public ClassA Person { get; set; }
        public ClassB Address { get; set; }
    }


这篇关于我不是在寻找具体的答案,而是更多的指导。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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