Program a number from the keyboard input, the output of the corresponding number of stars, shape random @ # % *, and will blink (threading)
Wrote but won't compile
CodePudding user response:
Show is defined as the virtual (virtual), rewriting in shooting Star class, has the Star class, meteor to inherit Star class?CodePudding user response:
Won't compile, posted on the error message or text format code is good for you to answer youCodePudding user response:
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
The namespace ConsoleApplication14
{
Public class Star,
{
Public int X;
Public int Y;
The Random r=new Random ();
Public int x;
Public int y;
Public Star (int num)
{
For (int I=0; I & lt; num; I++)
{
Int g=r.N ext (5);
Int k=r.N ext (5);
Char [] shapes={' + ', '*', '& amp; ', ', ', '#'};
The Console. ForegroundColor=g (ConsoleColor);
The Console. SetCursorPosition (r.N ext (100), r.N ext (20));
The Console. Write (" {0} ", shapes [k]);
}
}
Public Star (int x, int y)
{
//TODO: Complete member initialization
This.=x x;
This. Y=y;
}
Public virtual void Show (int x, int y)
{
X=X;
Y=Y;
The Console. SetCursorPosition (x, y);
}
Internal void Show ()
{
Throw new NotImplementedException ();
}
}
}
CodePudding user response:
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
The namespace ConsoleApplication14
{
Class Meteor: Star,
{
Public Meteor (int x, int y) : the base (x, y)
{
Console. WriteLine ();
}
Public override void Show (int x, int y)
{
Base. The Show ();
While (true)
{
X=X;
Y=Y;
The Console. SetCursorPosition (x + 1, y + 1);
}
}
}
}
CodePudding user response:
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
Using System. The Threading;
The namespace ConsoleApplication14
{
Class Program
{
List
The static void Main (string [] args)
{
Console. WriteLine (" input number of the stars: ");
Int num=the Convert. ToInt32 (Console. ReadLine ());
The Console. The Clear ();
Star Star1=new Star (num);
The Console. ReadLine ();
}
}
}