Created
June 4, 2018 02:06
-
-
Save janell-baxter/c3fb9ebe646e4807b6d662366688de6c to your computer and use it in GitHub Desktop.
Introduction to Programming Day Two (Summer 2018) Simple Application Example: Make a Bee!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace DayTwoBumblebee | |
{ | |
class Bumblebee | |
{ | |
//data | |
public string Color = "yellow and black"; | |
public double Size = 10; | |
public bool Fuzzy = true; | |
public string Name = "The anonymous bee"; | |
//constructor | |
public Bumblebee() | |
{ | |
} | |
public Bumblebee(string name) | |
{ | |
Name = name; | |
} | |
//operations | |
public void Fly() { | |
string fuzziness = "not fuzzy"; | |
if (Fuzzy) | |
{ | |
fuzziness = "fuzzy"; | |
} | |
Console.WriteLine(Name + ", which is a " + Size + " millimeter " + Color + " " + fuzziness + " bee, flies like a B6."); | |
} | |
public void Collect() { } | |
public void Generate() { } | |
public void HighFive() { } | |
public void Sound() { } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace DayTwoBumblebee | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
//title for the application title bar | |
Console.Title = "Make a Bee!"; | |
//variables | |
string name; | |
string color; | |
int size; | |
bool fuzzy = false; | |
string input; | |
Console.WriteLine("Welcome to the \"Amazing\" Make A Bee app!"); | |
Console.WriteLine("What would you like to name the bee?"); | |
name = Console.ReadLine(); | |
Console.WriteLine("Your bee will be two colors. One of those is black. What is the other color?"); | |
color = Console.ReadLine(); | |
color = color + " and black"; | |
Console.WriteLine("What size (in millimeters) is your bee? Bees are usually between 10-32 millimeters."); | |
size = Convert.ToInt32(Console.ReadLine()); | |
//input = Console.ReadLine(); | |
//size = Convert.ToInt32(input); | |
Console.WriteLine("Is your bee fuzzy? Please answer yes or no."); | |
input = Console.ReadLine(); | |
if (input.ToLower() == "yes") | |
{ | |
fuzzy = true; | |
} | |
Console.WriteLine("Your bee: " + name + " is " + color + ", and is " + size + " millimeters. " + name + "'s fuzzy state is " + fuzzy + "."); | |
Console.WriteLine("Press enter to continue..."); | |
Console.ReadKey(); | |
Console.Clear(); | |
//create an instance of the Bumblebee class, the identifier name is bee1 | |
Bumblebee bee1 = new Bumblebee(); | |
bee1.Fuzzy = false; | |
bee1.Size = 30; | |
bee1.Name = "Big Meany Pants"; | |
bee1.Color = "red and black"; | |
//create an instance of the Bumblebee class, the identifier name is bee2 | |
Bumblebee bee2 = new Bumblebee("Steven J. Barry"); | |
bee1.Fly(); | |
bee2.Fly(); | |
Console.WriteLine("\n\nExample of concatenation of a string plus a number, and of a number:"); | |
string score = "10"; | |
int Score = 10; | |
Console.WriteLine("The score is " + (score + 1)); | |
Console.WriteLine("The score is " + (Score + 1)); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment