POS409 Week1 Pet’s Name

POS409 Week1 Pet's Name 1

Design, implement, test, and debug a C# program that displays a pet’s name when a button is clicked.

Create a graphical user interface (GUI) with a button labeled “Pet’s name.”
When the Pet’s name button is clicked, the program will display the name of the pet in a label on the form.

SlotMachine

SlotMachine 2

A slot machine is a gambling device into which the user inserts money and then pulls a lever (or presses a button). The slot machine then displays a set of random images.If two or more of the images match, the user wins an amount of money that the slot machine dispenses back to the user.Create an application that simulates a slot machine. The attached file shows an example of how the form should look. The application should let the user enter into a TextBox the amount of money he or she is inserting into the machine. When the user selects the Spin button, the application should display three randomly selected symbols. (Slot machines traditionally display fruit symbols. You will find a set of fruit symbols in the Images \ Fruit Symbols folder of the Student Sample Programs.)If none of the randomly displayed images match, the program should inform the user that he or she has won $0. If two of the images match, the program should inform the user that he or she has won two times the amount entered. If three of the images match, the program should inform the user that he or she has won three times the amount entered. When the user selects the Exit button to exit the application, the program should display the total amount of money entered into the slot machine during this session and the total amount won. Upon exit, the total amount won is appended to a file that records each session’s total winnings.

GuessingGame

GuessingGame 3

Create an application with a group of 3 radio buttons that generates a random number in the range of 1 to 10 if this “Novice” radio button is selected, 1 to 100 if the “Expert” radio button is selected, and 1 to 1,000 if the “Master” radio button is selected. Get the user’s name. Ask the user to guess the number. Have the game keep count of the number of guesses that the user makes.If the user’s guess is higher than the random number, the program should display “Too high, try again.” If the user’s guess is lower than the random number, the program should display “Too low, try again.” When the user correctly guesses the random number, the program should display the number of guesses and congratulate the user.Have the application save to a data file the correct number, the player’s name, and the number of attempts for that round. Make sure the file is formatted for later retrieval.At the end of each round, ask the user if he would like to play again. If yes is selected, the application should generate a new random number so the game can start over.Allow the user to change the player’s name for the current round.Add a checkbox labeled “Advanced.” When this is checked the user only gets an “incorrect, try again” message. So, you don’t tell the user which way to go to narrow the search.Add a button to “Display Previous Plays” that will show all the saved data in a message, properly formatted for display.

StackQueueCSProjectsWithFlowcharts

StackQueueCSProjectsWithFlowcharts 4

You will now look at Stacks and Queues using linked lists. Complete the following for this assignment:
1. Create a flowchart to show the process that will allow the implementation of Stack, Push, and Pop operations.
2. Create a flowchart to show the process that will allow the implementation of Queue, Enqueue, and Dequeue operations.
3. Write the required C# codes (and functions) to implement either a Stack or a Queuedata structure.

Factory Design Pattern

Factory Design Pattern 5

Reflection (System.Reflection) is a feature that is often used in design patterns such as the Factory design pattern. Write a short Visual Studio Window Form C# Solution program that uses reflection to implement a Factory design pattern.

CIS247A Week 7 Lab The Abstract Racer Inheritance Hierarchy Program

CIS247A Week 7 Lab The Abstract Racer Inheritance Hierarchy Program 6

CIS247A Week 7 Lab The Abstract Racer Inheritance Hierarchy Program

Scenario and Summary
This week, you will be implementing inheritance by creating a generic Racer base class along with two derived classes called StreetTuner and HotRod. You will make the Racer class abstract and include the abstract method IsDead() in the Racer class.

STEP 1: Understand the UML Diagram
The UML diagram four classes defined (1) Racer, (2) Engine, (3) Hot Rod, and (4) StreetTuner classes.

The Racer class is the base parent abstract class of the Hot Rod and Street Tuner classes, which is represented by a directed line from the Hot Rod and Street Tuner classes to the Racer class and the end of the line touching the Racer class is a broad, unfilled arrow head. The racer class contains a engine object, which is represented by a directed line from the engine class to the Racer class, with a filled diamond touching the racer class, this line is labeled as a 1 to 1 relationship meaning that each racer object will contain one engine object and each engine is related to a single racer object.

The class’s attributes and methods are defined in separate class diagrams, and each class diagram is represented by a rectangular box subdivided into three vertically separated rectangular sub-sections. The top section contains the class name, the middle section contains the class attributes, and the bottom section contains the class methods.

STEP 2: Build the Inheritance Hierarchy
1. Create a project called “CIS247_WK7_Lab_LASTNAME”.
2. Build the class structure shown in the UML diagram. Remember to include properties for each class attribute.

STEP 3: Implement the Logic for the HotRod Class
1. Provide suitable logic for the ToString method. As always, the ToString method should reveal the state of an object.
2. For the IsDead() method in HotRod, use the logic to implement the base class abstract IsDead method.
Hint: To generate a random number, use the following code, which returns a random number from 0 to 1:
Random rnd = new Random();
rnd.NextDouble();

Pseudocode for the IsDead method of HotRod
Random rnd = new Random();
boolean dead

if (speed > 50 && rnd.NextDouble() > 0.6)
if (engineHorsePower < 300 && blower=true) dead = false else dead = true end if else if (speed > 100 && rnd.NextDouble() > 0.4)
if (engineHorsePower >= 300 && blower = true)
dead = true
else
dead = false
end if
else
dead = false
end if

STEP 4: Implement the logic for the StreetTurner class
1. Provide suitable logic for the ToString method. As always, the ToString method should reveal the state of an object.
2. For the IsDead method in StreetTurner, use the logic below to implement the inherited abstract base class method called IsDead.

Pseudocode for the IsDead method of StreetTuner
Random rnd = new Random();
boolean dead
if (speed > 50 && rnd.NextDouble() > 0.6)
if (engineHorsePower < 300 && nitrous=true) dead = false else dead = true end if else if (speed > 100 && rnd.NextDouble() > 0.4)
if (engineHorsePower >= 300 && nitrous = true)
dead = true
else
dead = false
end if
else
dead = false
end if

STEP5: Construct the Main Program
1. Create an array of Racer objects that will hold two Racer objects.
2. Write a method called CollectRacerInformation that accepts as an argument a Racer object, and then prompts the user to provide the following information for each racer:
a. Racer name;
b. Racer Speed;
c. Number of cylinders in the racer’s engine;
d. Horsepower of the racer’s engine; and
e. Nitrus or blower option, depending on the type of Racer object.
[Hint: In order to be able to collect all information for the derived classes as well, consider creating a base class method called ReadRacerData in the Racer class, which you will then override in the derived classes to capture the required info per class. Call the ReadRacerData method within the CollectRacerInformation method.]
3. Write a method called “DisplayRacerInformation” that accepts as an argument a Racer object, and then displays all of the information for the specific racer type.
4. Create a racer object of each type, and invoke the CollectRacerInformation passing in the Racer object. Then, store each object in the array.
5. Iterate through the Racer array list and, for each Racer, display all of the Racer’s attribute information (call the DisplayRacerInformation method for each object). Don’t forget to indicate whether or not the Racer is dead!

STEP 6: Compile and Test
When done, compile and run your program.
Then, debug any errors until your code is error-free.
Check your output to ensure that you have the desired output and modify your code as necessary and rebuild. Your code may resemble the following:

Welcome the Abstract RAcer Inheritance Hierarchy Program
CIS247, Week 7 Lab
Name: Solution
This Program test an Anstract Racer Inheritance hierarchy
**************** Collecting Racer’s Basic Data ****************
Enter racer’s name: Fast One
Enter racer’s speed: 345
Enter number of cylinders in racer’s engine: 20
Enter horsepower of racer’s engine: 250
Enter nitrus option (Y/N): Y
**************** Collecting Racer’s Basic Data ****************
Enter racer’s name: Lightning
Enter racer’s speed: 380
Enter number of cylinders in racer’s engine: 16
Enter horsepower or racer’s engine: 275
Enter blower option (Y/N): Y
**************** Display Racer’s Data ****************
Racer’s Name : Fast One
Racer’s Speed : 345
Engine Cylinders : 20
Engine Horsepower : 250
Racer’s Type : STREET TUNER
With Nitrus Option : Yes
Still Working? : Yes!
**************** Display Racer’s Data ****************
Racer’s Name : Lightning
Racer’s Speed : 380
Engine Cylinders : 16
Engine Horsepower : 275
Racer’s Type : HOT ROD
With Nitrus Option : Yes
Still Working? : Yes!
Thank you for using the Abstract Racer Inheritance Hierarchy

Simple Calculator (Console Application)

Simple Calculator (Console Application) 7

A simple calculator (Console Application) C#
1. Make a console application of a calculator that does simple addition, subtraction,
multiplication, and division.
? Enter any number in the console at runtime
? Choose any operator from +, -, * or / and enter it
? Enter another number
? When you press Enter, the operations are ran
? Only allow numbers as operands
? Only allow the choice of valid operators: +, -, *, and /
? Does not allow divide by zero
This program should allow the user to either continue or quit after each operation. That
is, the program should not crash or quit on its own after an operation.
In the second part, floating-point operations are required.

CIS247 Week 6

CIS247 Week 6 8

Create a new project and name it CIS247C_WK6_Lab_LASTNAME. Copy all the source files from the Week 5 project into the Week 6 project.

Before you move on to the next step, build and execute the Week 6 project.

STEP 3: Modify the Employee Class

Define calculatePay() as a pure virtual function. Define displayEmployee() as a pure virtual function. When class Employee contains two pure virtual functions, it becomes an abstract class.

STEP 4: Create Generalized Input Methods

Reuse method getInput() from the previous iLab to prompt the user to enter Employee information.

STEP 5: Modify the Main Method

Create two employee pointers with:

Employee * Salaried(10000,3); Employee * Hourly(50, 40, “full time”);

The first employee pointer refers to a salaried employee and the second employee pointer refers to a hourly employee.

Prompt the user to enter information for these two pointers and display the calculated result.

For salaried employee, the following information needs to be displayed:

Partial Sample Output:

Screenshot of program output that reads: Employee Information ________________________________________ Name: Nana Liu Gender: F Annual Salary: 60000.00 Weekly Salary: 1500.00 Benefit Information ________________________________________ Health Insurance: PPO Life Insurance: 1.50 Vacation: 21 days Salaried Employee Management level: 3

For hourly employee, the following information needs to be displayed:

Partial Sample Output:

Screenshot of program output that reads: Name: Jackie Chan Gender: M Dependents: 1 Annual Salary: 100000.00 Weekly Salary: 2000.00 Benefit Information ________________________________________ Health Insurance: HMO Life Insurance: 100.00 Vacation: 18 days Hourly Employee Category: full time Wage: 50.00 Hours: 40.00

Input Validation

Input Validation 9

Design, implement, test, and debug a C# program to demonstrate input validation using regular expressions. The program should contain input fields for a customer name, a part number, an order quantity, and a unit cost. It may contain other fields that you might see on a typical order entry form. Please note that the use of masked textboxes is not acceptable. The program should validate at least one type of data of your choice – you are free to choose a commonly used data format such as Social Security Number (999-99-9999), or phone number (999-999-9999), or a custom format that you design. The program should also validate the part number in the following format: an 8 digit prefix consisting of capital letters or numbers followed by a dash followed by a two digit suffix that can only be zeroes or ones. Last the program should also perform a “sanity check” on one of the input fields. For instance, you could validate the order quantity to ensure it is not too large (such as greater than 500). This program must be a Windows Forms application. Be sure the interface is professional looking and intuitive to use for the novice end user.

Custom Exception

Custom Exception 10

Design, implement, test, and debug a C# program to demonstrate exception handling. The program must include the creation of a custom exception. This program may be a console application or a Windows Forms application.

×
New Download