7 kyu

Thinkful - Object Drills: Quarks

2,453 of 3,831Grae-Drake

Description:

Background

You're modelling the interaction between a large number of quarks and have decided to create a Quark class so you can generate your own quark objects.

Quarks are fundamental particles and the only fundamental particle to experience all four fundamental forces.

Your task

Your Quark class should allow you to create quarks of any valid color ("red", "blue", and "green") and any valid flavor ('up', 'down', 'strange', 'charm', 'top', and 'bottom').

Every quark has the same baryon_number (BaryonNumber in C#): 1/3.

Every quark should have an .interact() (.Interact() in C#) method that allows any quark to interact with another quark via the strong force. When two quarks interact they exchange colors.

Example

>>> q1 = Quark("red", "up")
>>> q1.color
"red"
>>> q1.flavor
"up"
>>> q2 = Quark("blue", "strange")
>>> q2.color
"blue"
>>> q2.baryon_number
0.3333333333333333
>>> q1.interact(q2)
>>> q1.color
"blue"
>>> q2.color
"red"
>>> Quark q1 = new Quark("red", "up");
>>> q1.Color;
"red"
>>> Quark q2 = new Quark("blue", "strange");
>>> q2.Color;
"blue"
>>> q2.BaryonNumber;
0.3333333333333333
>>> q1.Interact(q2);
>>> q1.Color;
"blue"
>>> q2.Color;
"red"
[let
  "red" "up" <quark> :> q1
  q1 color>> .  ! "red"
  "blue" "strange" <quark> :> q2
  q2 color>> .  ! "blue"
  q2 baryon-number>> .  ! 1/3
  q1 q2 interact
  q1 color>> .  ! "blue"
  q2 color>> .  ! "red"
]
>>> q1 = Quark::new("red", "up")
>>> q1.color()
"red"
>>> q1.flavor()
"up"
>>> q2 = Quark::new("blue", "strange")
>>> q2.color()
"blue"
>>> q2.baryon_number()
0.3333333333333333_f64
>>> q1.interact(q2)
>>> q1.color
"blue"
>>> q2.color
"red"
Fundamentals
Object-oriented Programming

Stats:

CreatedJan 21, 2017
PublishedJan 21, 2017
Warriors Trained5364
Total Skips69
Total Code Submissions8681
Total Times Completed3831
Python Completions2453
JavaScript Completions949
C# Completions425
Factor Completions7
Rust Completions81
Total Stars54
% of votes with a positive feedback rating90% of 493
Total "Very Satisfied" Votes412
Total "Somewhat Satisfied" Votes68
Total "Not Satisfied" Votes13
Total Rank Assessments21
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Grae-Drake Avatar
  • ZozoFouchtra Avatar
  • anter69 Avatar
  • Souzooka Avatar
  • hobovsky Avatar
  • akar-0 Avatar
  • Kacarott Avatar
  • tri@ Avatar
  • farhanaditya Avatar
Ad